From fcb57cc3e2cbb3e16750e9ce8ddca069184ac1c0 Mon Sep 17 00:00:00 2001 From: HUI Date: Wed, 2 Dec 2020 14:59:38 +0800 Subject: [PATCH] feat: upgrade to 3.2.0 --- Annotations.java | 1629 +++++++++++++++++++++++--------------------- BeanCovertor.kt | 234 +++---- Callback.kt | 52 +- EnumCovertor.kt | 100 +-- Extensions.kt | 224 +++--- MediaObserver.kt | 48 +- RtcChannel.kt | 546 +++++++-------- RtcChannelEvent.kt | 412 +++++------ RtcEngine.kt | 1416 +++++++++++++++++++------------------- RtcEngineEvent.kt | 1004 +++++++++++++-------------- RtcSurfaceView.kt | 142 ++-- RtcTextureView.kt | 110 +-- 12 files changed, 3000 insertions(+), 2917 deletions(-) diff --git a/Annotations.java b/Annotations.java index 3e584a77d..54e7ba9a5 100644 --- a/Annotations.java +++ b/Annotations.java @@ -12,788 +12,849 @@ @SuppressWarnings("deprecation") public class Annotations { - @IntDef({ - AgoraRtcAppType.NATIVE, - AgoraRtcAppType.COCOS, - AgoraRtcAppType.UNITY, - AgoraRtcAppType.ELECTRON, - AgoraRtcAppType.FLUTTER, - AgoraRtcAppType.UNREAL, - AgoraRtcAppType.XAMARIN, - AgoraRtcAppType.APICLOUD, - AgoraRtcAppType.REACTNATIVE, - }) - @Retention(RetentionPolicy.SOURCE) - public @interface AgoraRtcAppType { - int NATIVE = 0; - int COCOS = 1; - int UNITY = 2; - int ELECTRON = 3; - int FLUTTER = 4; - int UNREAL = 5; - int XAMARIN = 6; - int APICLOUD = 7; - int REACTNATIVE = 8; - } - - @IntDef({ - AgoraAudioCodecProfileType.LC_AAC, - AgoraAudioCodecProfileType.HE_AAC, - }) - @Retention(RetentionPolicy.SOURCE) - public @interface AgoraAudioCodecProfileType { - int LC_AAC = 0; - int HE_AAC = 1; - } - - @IntDef({ - Constants.AUDIO_EQUALIZATION_BAND_31, - Constants.AUDIO_EQUALIZATION_BAND_62, - Constants.AUDIO_EQUALIZATION_BAND_125, - Constants.AUDIO_EQUALIZATION_BAND_250, - Constants.AUDIO_EQUALIZATION_BAND_500, - Constants.AUDIO_EQUALIZATION_BAND_1K, - Constants.AUDIO_EQUALIZATION_BAND_2K, - Constants.AUDIO_EQUALIZATION_BAND_4K, - Constants.AUDIO_EQUALIZATION_BAND_8K, - Constants.AUDIO_EQUALIZATION_BAND_16K, - }) - @Retention(RetentionPolicy.SOURCE) - public @interface AgoraAudioEqualizationBandFrequency { - } - - @IntDef({ - Constants.LOCAL_AUDIO_STREAM_ERROR_OK, - Constants.LOCAL_AUDIO_STREAM_ERROR_FAILURE, - Constants.LOCAL_AUDIO_STREAM_ERROR_DEVICE_NO_PERMISSION, - Constants.LOCAL_AUDIO_STREAM_ERROR_DEVICE_BUSY, - Constants.LOCAL_AUDIO_STREAM_ERROR_CAPTURE_FAILURE, - Constants.LOCAL_AUDIO_STREAM_ERROR_ENCODE_FAILURE, - }) - @Retention(RetentionPolicy.SOURCE) - public @interface AgoraAudioLocalError { - } - - @IntDef({ - Constants.LOCAL_AUDIO_STREAM_STATE_STOPPED, - Constants.LOCAL_AUDIO_STREAM_STATE_CAPTURING, - Constants.LOCAL_AUDIO_STREAM_STATE_ENCODING, - Constants.LOCAL_AUDIO_STREAM_STATE_FAILED, - }) - @Retention(RetentionPolicy.SOURCE) - public @interface AgoraAudioLocalState { - } - - @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 { - 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_STOPPED, - Constants.MEDIA_ENGINE_AUDIO_EVENT_MIXING_ERROR, - }) - @Retention(RetentionPolicy.SOURCE) - public @interface AgoraAudioMixingStateCode { - } - - @IntDef({ - Constants.AUDIO_ROUTE_DEFAULT, - Constants.AUDIO_ROUTE_HEADSET, - Constants.AUDIO_ROUTE_EARPIECE, - Constants.AUDIO_ROUTE_HEADSETNOMIC, - Constants.AUDIO_ROUTE_SPEAKERPHONE, - Constants.AUDIO_ROUTE_LOUDSPEAKER, - Constants.AUDIO_ROUTE_HEADSETBLUETOOTH, - }) - @Retention(RetentionPolicy.SOURCE) - public @interface AgoraAudioOutputRouting { - } - - @IntDef({ - Constants.AUDIO_PROFILE_DEFAULT, - Constants.AUDIO_PROFILE_SPEECH_STANDARD, - Constants.AUDIO_PROFILE_MUSIC_STANDARD, - Constants.AUDIO_PROFILE_MUSIC_STANDARD_STEREO, - Constants.AUDIO_PROFILE_MUSIC_HIGH_QUALITY, - Constants.AUDIO_PROFILE_MUSIC_HIGH_QUALITY_STEREO, - }) - @Retention(RetentionPolicy.SOURCE) - public @interface AgoraAudioProfile { - } - - @IntDef({ - Constants.AUDIO_RECORDING_QUALITY_LOW, - Constants.AUDIO_RECORDING_QUALITY_MEDIUM, - Constants.AUDIO_RECORDING_QUALITY_HIGH, - }) - @Retention(RetentionPolicy.SOURCE) - public @interface AgoraAudioRecordingQuality { - } - - @IntDef({ - Constants.REMOTE_AUDIO_STATE_STOPPED, - Constants.REMOTE_AUDIO_STATE_STARTING, - Constants.REMOTE_AUDIO_STATE_DECODING, - Constants.REMOTE_AUDIO_STATE_FROZEN, - Constants.REMOTE_AUDIO_STATE_FAILED, - }) - @Retention(RetentionPolicy.SOURCE) - public @interface AgoraAudioRemoteState { - } - - @IntDef({ - Constants.REMOTE_AUDIO_REASON_INTERNAL, - Constants.REMOTE_AUDIO_REASON_NETWORK_CONGESTION, - Constants.REMOTE_AUDIO_REASON_NETWORK_RECOVERY, - Constants.REMOTE_AUDIO_REASON_LOCAL_MUTED, - Constants.REMOTE_AUDIO_REASON_LOCAL_UNMUTED, - Constants.REMOTE_AUDIO_REASON_REMOTE_MUTED, - Constants.REMOTE_AUDIO_REASON_REMOTE_UNMUTED, - Constants.REMOTE_AUDIO_REASON_REMOTE_OFFLINE, - }) - @Retention(RetentionPolicy.SOURCE) - public @interface AgoraAudioRemoteStateReason { - } - - @IntDef({ - Constants.AUDIO_REVERB_OFF, - Constants.AUDIO_REVERB_POPULAR, - Constants.AUDIO_REVERB_RNB, - Constants.AUDIO_REVERB_ROCK, - Constants.AUDIO_REVERB_HIPHOP, - Constants.AUDIO_REVERB_VOCAL_CONCERT, - Constants.AUDIO_REVERB_KTV, - Constants.AUDIO_REVERB_STUDIO, - Constants.AUDIO_REVERB_FX_KTV, - Constants.AUDIO_REVERB_FX_VOCAL_CONCERT, - Constants.AUDIO_REVERB_FX_UNCLE, - Constants.AUDIO_REVERB_FX_SISTER, - Constants.AUDIO_REVERB_FX_STUDIO, - Constants.AUDIO_REVERB_FX_POPULAR, - Constants.AUDIO_REVERB_FX_RNB, - Constants.AUDIO_REVERB_FX_PHONOGRAPH, - Constants.AUDIO_VIRTUAL_STEREO, - }) - @Retention(RetentionPolicy.SOURCE) - public @interface AgoraAudioReverbPreset { - } - - @IntDef({ - Constants.AUDIO_REVERB_DRY_LEVEL, - Constants.AUDIO_REVERB_WET_LEVEL, - Constants.AUDIO_REVERB_ROOM_SIZE, - Constants.AUDIO_REVERB_WET_DELAY, - Constants.AUDIO_REVERB_STRENGTH, - }) - @Retention(RetentionPolicy.SOURCE) - public @interface AgoraAudioReverbType { - } - - @IntDef({ - AgoraAudioSampleRateType.TYPE_32000, - AgoraAudioSampleRateType.TYPE_44100, - AgoraAudioSampleRateType.TYPE_48000, - }) - @Retention(RetentionPolicy.SOURCE) - public @interface AgoraAudioSampleRateType { - int TYPE_32000 = 32000; - int TYPE_44100 = 44100; - int TYPE_48000 = 48000; - } - - @IntDef({ - Constants.AUDIO_SCENARIO_DEFAULT, - Constants.AUDIO_SCENARIO_CHATROOM_ENTERTAINMENT, - Constants.AUDIO_SCENARIO_EDUCATION, - Constants.AUDIO_SCENARIO_GAME_STREAMING, - Constants.AUDIO_SCENARIO_SHOWROOM, - Constants.AUDIO_SCENARIO_CHATROOM_GAMING, - }) - @Retention(RetentionPolicy.SOURCE) - public @interface AgoraAudioScenario { - } - - @IntDef({ - Constants.VOICE_CHANGER_OFF, - Constants.VOICE_CHANGER_OLDMAN, - Constants.VOICE_CHANGER_BABYBOY, - Constants.VOICE_CHANGER_BABYGIRL, - Constants.VOICE_CHANGER_ZHUBAJIE, - Constants.VOICE_CHANGER_ETHEREAL, - Constants.VOICE_CHANGER_HULK, - Constants.VOICE_BEAUTY_VIGOROUS, - Constants.VOICE_BEAUTY_DEEP, - Constants.VOICE_BEAUTY_MELLOW, - Constants.VOICE_BEAUTY_FALSETTO, - Constants.VOICE_BEAUTY_FULL, - Constants.VOICE_BEAUTY_CLEAR, - Constants.VOICE_BEAUTY_RESOUNDING, - Constants.VOICE_BEAUTY_RINGING, - Constants.VOICE_BEAUTY_SPACIAL, - Constants.GENERAL_BEAUTY_VOICE_MALE_MAGNETIC, - Constants.GENERAL_BEAUTY_VOICE_FEMALE_FRESH, - Constants.GENERAL_BEAUTY_VOICE_FEMALE_VITALITY, - }) - @Retention(RetentionPolicy.SOURCE) - public @interface AgoraAudioVoiceChanger { - } - - @IntDef({ - AgoraCameraCaptureOutputPreference.CAPTURER_OUTPUT_PREFERENCE_AUTO, - AgoraCameraCaptureOutputPreference.CAPTURER_OUTPUT_PREFERENCE_PERFORMANCE, - AgoraCameraCaptureOutputPreference.CAPTURER_OUTPUT_PREFERENCE_PREVIEW, - }) - @Retention(RetentionPolicy.SOURCE) - public @interface AgoraCameraCaptureOutputPreference { - int CAPTURER_OUTPUT_PREFERENCE_AUTO = 0; - int CAPTURER_OUTPUT_PREFERENCE_PERFORMANCE = 1; - int CAPTURER_OUTPUT_PREFERENCE_PREVIEW = 2; - } - - @IntDef({ - AgoraCameraDirection.CAMERA_REAR, - AgoraCameraDirection.CAMERA_FRONT, - }) - @Retention(RetentionPolicy.SOURCE) - public @interface AgoraCameraDirection { - int CAMERA_REAR = 0; - int CAMERA_FRONT = 1; - } - - @IntDef({ - Constants.RELAY_OK, - Constants.RELAY_ERROR_SERVER_ERROR_RESPONSE, - Constants.RELAY_ERROR_SERVER_NO_RESPONSE, - Constants.RELAY_ERROR_NO_RESOURCE_AVAILABLE, - Constants.RELAY_ERROR_FAILED_JOIN_SRC, - Constants.RELAY_ERROR_FAILED_JOIN_DEST, - Constants.RELAY_ERROR_FAILED_PACKET_RECEIVED_FROM_SRC, - Constants.RELAY_ERROR_FAILED_PACKET_SENT_TO_DEST, - Constants.RELAY_ERROR_SERVER_CONNECTION_LOST, - Constants.RELAY_ERROR_INTERNAL_ERROR, - Constants.RELAY_ERROR_SRC_TOKEN_EXPIRED, - Constants.RELAY_ERROR_DEST_TOKEN_EXPIRED, - }) - @Retention(RetentionPolicy.SOURCE) - public @interface AgoraChannelMediaRelayError { - } - - @IntDef({ - Constants.RELAY_EVENT_NETWORK_DISCONNECTED, - Constants.RELAY_EVENT_NETWORK_CONNECTED, - Constants.RELAY_EVENT_PACKET_JOINED_SRC_CHANNEL, - Constants.RELAY_EVENT_PACKET_JOINED_DEST_CHANNEL, - Constants.RELAY_EVENT_PACKET_SENT_TO_DEST_CHANNEL, - Constants.RELAY_EVENT_PACKET_RECEIVED_VIDEO_FROM_SRC, - Constants.RELAY_EVENT_PACKET_RECEIVED_AUDIO_FROM_SRC, - Constants.RELAY_EVENT_PACKET_UPDATE_DEST_CHANNEL, - Constants.RELAY_EVENT_PACKET_UPDATE_DEST_CHANNEL_REFUSED, - Constants.RELAY_EVENT_PACKET_UPDATE_DEST_CHANNEL_NOT_CHANGE, - Constants.RELAY_EVENT_PACKET_UPDATE_DEST_CHANNEL_IS_NULL, - Constants.RELAY_EVENT_VIDEO_PROFILE_UPDATE, - }) - @Retention(RetentionPolicy.SOURCE) - public @interface AgoraChannelMediaRelayEvent { - } - - @IntDef({ - Constants.RELAY_STATE_IDLE, - Constants.RELAY_STATE_CONNECTING, - Constants.RELAY_STATE_RUNNING, - Constants.RELAY_STATE_FAILURE, - }) - @Retention(RetentionPolicy.SOURCE) - public @interface AgoraChannelMediaRelayState { - } - - @IntDef({ - Constants.CHANNEL_PROFILE_COMMUNICATION, - Constants.CHANNEL_PROFILE_LIVE_BROADCASTING, - Constants.CHANNEL_PROFILE_GAME, - }) - @Retention(RetentionPolicy.SOURCE) - public @interface AgoraChannelProfile { - } - - @IntDef({ - Constants.CLIENT_ROLE_BROADCASTER, - Constants.CLIENT_ROLE_AUDIENCE, - }) - @Retention(RetentionPolicy.SOURCE) - public @interface AgoraClientRole { - } - - @IntDef({ - Constants.CONNECTION_CHANGED_CONNECTING, - Constants.CONNECTION_CHANGED_JOIN_SUCCESS, - Constants.CONNECTION_CHANGED_INTERRUPTED, - Constants.CONNECTION_CHANGED_BANNED_BY_SERVER, - Constants.CONNECTION_CHANGED_JOIN_FAILED, - Constants.CONNECTION_CHANGED_LEAVE_CHANNEL, - Constants.CONNECTION_CHANGED_INVALID_APP_ID, - Constants.CONNECTION_CHANGED_INVALID_CHANNEL_NAME, - Constants.CONNECTION_CHANGED_INVALID_TOKEN, - Constants.CONNECTION_CHANGED_TOKEN_EXPIRED, - Constants.CONNECTION_CHANGED_REJECTED_BY_SERVER, - Constants.CONNECTION_CHANGED_SETTING_PROXY_SERVER, - Constants.CONNECTION_CHANGED_RENEW_TOKEN, - Constants.CONNECTION_CHANGED_CLIENT_IP_ADDRESS_CHANGED, - Constants.CONNECTION_CHANGED_KEEP_ALIVE_TIMEOUT, - }) - @Retention(RetentionPolicy.SOURCE) - public @interface AgoraConnectionChangedReason { - } - - @IntDef({ - Constants.CONNECTION_STATE_DISCONNECTED, - Constants.CONNECTION_STATE_CONNECTING, - Constants.CONNECTION_STATE_CONNECTED, - Constants.CONNECTION_STATE_RECONNECTING, - Constants.CONNECTION_STATE_FAILED, - }) - @Retention(RetentionPolicy.SOURCE) - public @interface AgoraConnectionStateType { - } - - @IntDef({ - AgoraDegradationPreference.MAINTAIN_QUALITY, - AgoraDegradationPreference.MAINTAIN_FRAMERATE, - AgoraDegradationPreference.MAINTAIN_BALANCED, - }) - @Retention(RetentionPolicy.SOURCE) - public @interface AgoraDegradationPreference { - int MAINTAIN_QUALITY = 0; - int MAINTAIN_FRAMERATE = 1; - int MAINTAIN_BALANCED = 2; - } - - @IntDef({ - AgoraEncryptionMode.NONE, - AgoraEncryptionMode.AES128XTS, - AgoraEncryptionMode.AES128ECB, - AgoraEncryptionMode.AES256XTS, - AgoraEncryptionMode.SM4128ECB, - }) - @Retention(RetentionPolicy.SOURCE) - public @interface AgoraEncryptionMode { - int NONE = 0; - int AES128XTS = 1; - int AES128ECB = 2; - int AES256XTS = 3; - int SM4128ECB = 4; - } - - @IntDef({ - Constants.ERR_OK, - Constants.ERR_FAILED, - Constants.ERR_INVALID_ARGUMENT, - Constants.ERR_NOT_READY, - Constants.ERR_NOT_SUPPORTED, - Constants.ERR_REFUSED, - Constants.ERR_BUFFER_TOO_SMALL, - Constants.ERR_NOT_INITIALIZED, - Constants.ERR_NO_PERMISSION, - Constants.ERR_TIMEDOUT, - Constants.ERR_CANCELED, - Constants.ERR_TOO_OFTEN, - Constants.ERR_BIND_SOCKET, - Constants.ERR_NET_DOWN, - Constants.ERR_NET_NOBUFS, - Constants.ERR_JOIN_CHANNEL_REJECTED, - Constants.ERR_LEAVE_CHANNEL_REJECTED, - Constants.ERR_ALREADY_IN_USE, - Constants.ERR_INVALID_APP_ID, - Constants.ERR_INVALID_CHANNEL_NAME, - Constants.ERR_NO_SERVER_RESOURCES, - Constants.ERR_TOKEN_EXPIRED, - Constants.ERR_INVALID_TOKEN, - Constants.ERR_CONNECTION_INTERRUPTED, - Constants.ERR_CONNECTION_LOST, - Constants.ERR_NOT_IN_CHANNEL, - Constants.ERR_SIZE_TOO_LARGE, - Constants.ERR_BITRATE_LIMIT, - Constants.ERR_TOO_MANY_DATA_STREAMS, - Constants.ERR_DECRYPTION_FAILED, - Constants.ERR_CLIENT_IS_BANNED_BY_SERVER, - Constants.ERR_WATERMARK_PARAM, - Constants.ERR_WATERMARK_PATH, - Constants.ERR_WATERMARK_PNG, - Constants.ERR_WATERMARKR_INFO, - Constants.ERR_WATERMARK_ARGB, - Constants.ERR_WATERMARK_READ, - Constants.ERR_ENCRYPTED_STREAM_NOT_ALLOWED_PUBLISHED, - Constants.ERR_INVALID_USER_ACCOUNT, - Constants.ERR_PUBLISH_STREAM_CDN_ERROR, - Constants.ERR_PUBLISH_STREAM_NUM_REACH_LIMIT, - Constants.ERR_PUBLISH_STREAM_NOT_AUTHORIZED, - Constants.ERR_PUBLISH_STREAM_INTERNAL_SERVER_ERROR, - Constants.ERR_PUBLISH_STREAM_NOT_FOUND, - Constants.ERR_PUBLISH_STREAM_FORMAT_NOT_SUPPORTED, - Constants.ERR_LOAD_MEDIA_ENGINE, - Constants.ERR_START_CALL, - Constants.ERR_START_CAMERA, - Constants.ERR_START_VIDEO_RENDER, - Constants.ERR_ADM_GENERAL_ERROR, - Constants.ERR_ADM_JAVA_RESOURCE, - Constants.ERR_ADM_SAMPLE_RATE, - Constants.ERR_ADM_INIT_PLAYOUT, - Constants.ERR_ADM_START_PLAYOUT, - Constants.ERR_ADM_STOP_PLAYOUT, - Constants.ERR_ADM_INIT_RECORDING, - Constants.ERR_ADM_START_RECORDING, - Constants.ERR_ADM_STOP_RECORDING, - Constants.ERR_ADM_RUNTIME_PLAYOUT_ERROR, - Constants.ERR_ADM_RUNTIME_RECORDING_ERROR, - Constants.ERR_ADM_RECORD_AUDIO_FAILED, - Constants.ERR_ADM_INIT_LOOPBACK, - Constants.ERR_ADM_START_LOOPBACK, - Constants.ERR_AUDIO_BT_SCO_FAILED, - Constants.ERR_ADM_NO_RECORDING_DEVICE, - Constants.ERR_ADM_NO_PLAYOUT_DEVICE, - Constants.ERR_VDM_CAMERA_NOT_AUTHORIZED, - Constants.ERR_VCM_UNKNOWN_ERROR, - Constants.ERR_VCM_ENCODER_INIT_ERROR, - Constants.ERR_VCM_ENCODER_ENCODE_ERROR, - Constants.ERR_VCM_ENCODER_SET_ERROR, - }) - @Retention(RetentionPolicy.SOURCE) - public @interface AgoraErrorCode { - } - - @IntDef({ - Constants.INJECT_STREAM_STATUS_START_SUCCESS, - Constants.INJECT_STREAM_STATUS_START_ALREADY_EXISTS, - Constants.INJECT_STREAM_STATUS_START_UNAUTHORIZED, - Constants.INJECT_STREAM_STATUS_START_TIMEDOUT, - Constants.INJECT_STREAM_STATUS_START_FAILED, - Constants.INJECT_STREAM_STATUS_STOP_SUCCESS, - Constants.INJECT_STREAM_STATUS_STOP_NOT_FOUND, - Constants.INJECT_STREAM_STATUS_STOP_UNAUTHORIZED, - Constants.INJECT_STREAM_STATUS_STOP_TIMEDOUT, - Constants.INJECT_STREAM_STATUS_STOP_FAILED, - Constants.INJECT_STREAM_STATUS_BROKEN, - }) - @Retention(RetentionPolicy.SOURCE) - public @interface AgoraInjectStreamStatus { - } - - @IntDef({ - Constants.LASTMILE_PROBE_RESULT_COMPLETE, - Constants.LASTMILE_PROBE_RESULT_INCOMPLETE_NO_BWE, - Constants.LASTMILE_PROBE_RESULT_UNAVAILABLE, - }) - @Retention(RetentionPolicy.SOURCE) - public @interface AgoraLastmileProbeResultState { - } - - @IntDef({ - BeautyOptions.LIGHTENING_CONTRAST_LOW, - BeautyOptions.LIGHTENING_CONTRAST_NORMAL, - BeautyOptions.LIGHTENING_CONTRAST_HIGH, - }) - @Retention(RetentionPolicy.SOURCE) - public @interface AgoraLighteningContrastLevel { - } - - @IntDef({ - Constants.LOCAL_VIDEO_STREAM_ERROR_OK, - Constants.LOCAL_VIDEO_STREAM_ERROR_FAILURE, - Constants.LOCAL_VIDEO_STREAM_ERROR_DEVICE_NO_PERMISSION, - Constants.LOCAL_VIDEO_STREAM_ERROR_DEVICE_BUSY, - Constants.LOCAL_VIDEO_STREAM_ERROR_CAPTURE_FAILURE, - Constants.LOCAL_VIDEO_STREAM_ERROR_ENCODE_FAILURE, - }) - @Retention(RetentionPolicy.SOURCE) - public @interface AgoraLocalVideoStreamError { - } - - @IntDef({ - Constants.LOCAL_VIDEO_STREAM_STATE_STOPPED, - Constants.LOCAL_VIDEO_STREAM_STATE_CAPTURING, - Constants.LOCAL_VIDEO_STREAM_STATE_ENCODING, - Constants.LOCAL_VIDEO_STREAM_STATE_FAILED, - }) - @Retention(RetentionPolicy.SOURCE) - public @interface AgoraLocalVideoStreamState { - } - - @IntDef({ - Constants.LOG_FILTER_OFF, - Constants.LOG_FILTER_DEBUG, - Constants.LOG_FILTER_INFO, - Constants.LOG_FILTER_WARNING, - Constants.LOG_FILTER_ERROR, - Constants.LOG_FILTER_CRITICAL, - }) - @Retention(RetentionPolicy.SOURCE) - public @interface AgoraLogFilter { - } - - @IntDef({ - Constants.QUALITY_UNKNOWN, - Constants.QUALITY_EXCELLENT, - Constants.QUALITY_GOOD, - Constants.QUALITY_POOR, - Constants.QUALITY_BAD, - Constants.QUALITY_VBAD, - Constants.QUALITY_DOWN, - Constants.QUALITY_UNSUPPORTED, - Constants.QUALITY_DETECTING, - }) - @Retention(RetentionPolicy.SOURCE) - public @interface AgoraNetworkQuality { - } - - @IntDef({ - Constants.NETWORK_TYPE_UNKNOWN, - Constants.NETWORK_TYPE_DISCONNECTED, - Constants.NETWORK_TYPE_LAN, - Constants.NETWORK_TYPE_WIFI, - Constants.NETWORK_TYPE_MOBILE_2G, - Constants.NETWORK_TYPE_MOBILE_3G, - Constants.NETWORK_TYPE_MOBILE_4G, - }) - @Retention(RetentionPolicy.SOURCE) - public @interface AgoraNetworkType { - } - - @IntDef({ - Constants.RTMP_STREAM_PUBLISH_ERROR_OK, - Constants.RTMP_STREAM_PUBLISH_ERROR_INVALID_ARGUMENT, - Constants.RTMP_STREAM_PUBLISH_ERROR_ENCRYPTED_STREAM_NOT_ALLOWED, - Constants.RTMP_STREAM_PUBLISH_ERROR_CONNECTION_TIMEOUT, - Constants.RTMP_STREAM_PUBLISH_ERROR_INTERNAL_SERVER_ERROR, - Constants.RTMP_STREAM_PUBLISH_ERROR_RTMP_SERVER_ERROR, - Constants.RTMP_STREAM_PUBLISH_ERROR_TOO_OFTEN, - Constants.RTMP_STREAM_PUBLISH_ERROR_REACH_LIMIT, - Constants.RTMP_STREAM_PUBLISH_ERROR_NOT_AUTHORIZED, - Constants.RTMP_STREAM_PUBLISH_ERROR_STREAM_NOT_FOUND, - Constants.RTMP_STREAM_PUBLISH_ERROR_FORMAT_NOT_SUPPORTED, - }) - @Retention(RetentionPolicy.SOURCE) - public @interface AgoraRtmpStreamingErrorCode { - } - - @IntDef({ - Constants.RTMP_STREAM_PUBLISH_STATE_IDLE, - Constants.RTMP_STREAM_PUBLISH_STATE_CONNECTING, - Constants.RTMP_STREAM_PUBLISH_STATE_RUNNING, - Constants.RTMP_STREAM_PUBLISH_STATE_RECOVERING, - Constants.RTMP_STREAM_PUBLISH_STATE_FAILURE, - }) - @Retention(RetentionPolicy.SOURCE) - public @interface AgoraRtmpStreamingState { - } - - @IntDef({ - Constants.STREAM_FALLBACK_OPTION_DISABLED, - Constants.STREAM_FALLBACK_OPTION_VIDEO_STREAM_LOW, - Constants.STREAM_FALLBACK_OPTION_AUDIO_ONLY, - }) - @Retention(RetentionPolicy.SOURCE) - public @interface AgoraStreamFallbackOptions { - } - - @IntDef({ - Constants.USER_OFFLINE_QUIT, - Constants.USER_OFFLINE_DROPPED, - Constants.USER_OFFLINE_BECOME_AUDIENCE, - }) - @Retention(RetentionPolicy.SOURCE) - public @interface AgoraUserOfflineReason { - } - - @IntDef({ - Constants.USER_PRIORITY_HIGH, - Constants.USER_PRIORITY_NORANL, - }) - @Retention(RetentionPolicy.SOURCE) - public @interface AgoraUserPriority { - } - - @IntDef({ - AgoraVideoCodecProfileType.BASELINE, - AgoraVideoCodecProfileType.MAIN, - AgoraVideoCodecProfileType.HIGH, - }) - @Retention(RetentionPolicy.SOURCE) - public @interface AgoraVideoCodecProfileType { - int BASELINE = 66; - int MAIN = 77; - int HIGH = 100; - } - - @IntDef({ - AgoraVideoFrameRate.FRAME_RATE_FPS_1, - AgoraVideoFrameRate.FRAME_RATE_FPS_7, - AgoraVideoFrameRate.FRAME_RATE_FPS_10, - AgoraVideoFrameRate.FRAME_RATE_FPS_15, - AgoraVideoFrameRate.FRAME_RATE_FPS_24, - AgoraVideoFrameRate.FRAME_RATE_FPS_30, - }) - @Retention(RetentionPolicy.SOURCE) - public @interface AgoraVideoFrameRate { - int FRAME_RATE_FPS_1 = 1; - int FRAME_RATE_FPS_7 = 7; - int FRAME_RATE_FPS_10 = 10; - int FRAME_RATE_FPS_15 = 15; - int FRAME_RATE_FPS_24 = 24; - int FRAME_RATE_FPS_30 = 30; - } - - @IntDef({ - Constants.VIDEO_MIRROR_MODE_AUTO, - Constants.VIDEO_MIRROR_MODE_ENABLED, - Constants.VIDEO_MIRROR_MODE_DISABLED, - }) - @Retention(RetentionPolicy.SOURCE) - public @interface AgoraVideoMirrorMode { - } - - @IntDef({ - AgoraVideoOutputOrientationMode.ORIENTATION_MODE_ADAPTIVE, - AgoraVideoOutputOrientationMode.ORIENTATION_MODE_FIXED_LANDSCAPE, - AgoraVideoOutputOrientationMode.ORIENTATION_MODE_FIXED_PORTRAIT, - }) - @Retention(RetentionPolicy.SOURCE) - public @interface AgoraVideoOutputOrientationMode { - int ORIENTATION_MODE_ADAPTIVE = 0; - int ORIENTATION_MODE_FIXED_LANDSCAPE = 1; - int ORIENTATION_MODE_FIXED_PORTRAIT = 2; - } - - @IntDef({ - Constants.ADAPT_NONE, - Constants.ADAPT_UP_BANDWIDTH, - Constants.ADAPT_DOWN_BANDWIDTH, - }) - @Retention(RetentionPolicy.SOURCE) - public @interface AgoraVideoQualityAdaptIndication { - } - - @IntDef({ - Constants.REMOTE_VIDEO_STATE_STOPPED, - Constants.REMOTE_VIDEO_STATE_STARTING, - Constants.REMOTE_VIDEO_STATE_DECODING, - Constants.REMOTE_VIDEO_STATE_FROZEN, - Constants.REMOTE_VIDEO_STATE_FAILED, - }) - @Retention(RetentionPolicy.SOURCE) - public @interface AgoraVideoRemoteState { - } - - @IntDef({ - Constants.REMOTE_VIDEO_STATE_REASON_INTERNAL, - Constants.REMOTE_VIDEO_STATE_REASON_NETWORK_CONGESTION, - Constants.REMOTE_VIDEO_STATE_REASON_NETWORK_RECOVERY, - Constants.REMOTE_VIDEO_STATE_REASON_LOCAL_MUTED, - Constants.REMOTE_VIDEO_STATE_REASON_LOCAL_UNMUTED, - Constants.REMOTE_VIDEO_STATE_REASON_REMOTE_MUTED, - Constants.REMOTE_VIDEO_STATE_REASON_REMOTE_UNMUTED, - Constants.REMOTE_VIDEO_STATE_REASON_REMOTE_OFFLINE, - Constants.REMOTE_VIDEO_STATE_REASON_AUDIO_FALLBACK, - Constants.REMOTE_VIDEO_STATE_REASON_AUDIO_FALLBACK_RECOVERY, - }) - @Retention(RetentionPolicy.SOURCE) - public @interface AgoraVideoRemoteStateReason { - } - - @IntDef({ - VideoCanvas.RENDER_MODE_HIDDEN, - VideoCanvas.RENDER_MODE_FIT, - VideoCanvas.RENDER_MODE_ADAPTIVE, - VideoCanvas.RENDER_MODE_FILL, - }) - @Retention(RetentionPolicy.SOURCE) - public @interface AgoraVideoRenderMode { - } - - @IntDef({ - Constants.VIDEO_STREAM_HIGH, - Constants.VIDEO_STREAM_LOW, - }) - @Retention(RetentionPolicy.SOURCE) - public @interface AgoraVideoStreamType { - } - - @IntDef({ - Constants.WARN_INVALID_VIEW, - Constants.WARN_INIT_VIDEO, - Constants.WARN_PENDING, - Constants.WARN_NO_AVAILABLE_CHANNEL, - Constants.WARN_LOOKUP_CHANNEL_TIMEOUT, - Constants.WARN_LOOKUP_CHANNEL_REJECTED, - Constants.WARN_OPEN_CHANNEL_TIMEOUT, - Constants.WARN_OPEN_CHANNEL_REJECTED, - Constants.WARN_SWITCH_LIVE_VIDEO_TIMEOUT, - Constants.WARN_SET_CLIENT_ROLE_TIMEOUT, - Constants.WARN_SET_CLIENT_ROLE_NOT_AUTHORIZED, - Constants.WARN_OPEN_CHANNEL_INVALID_TICKET, - Constants.WARN_OPEN_CHANNEL_TRY_NEXT_VOS, - Constants.WARN_AUDIO_MIXING_OPEN_ERROR, - Constants.WARN_ADM_RUNTIME_PLAYOUT_WARNING, - Constants.WARN_ADM_RUNTIME_RECORDING_WARNING, - Constants.WARN_ADM_RECORD_AUDIO_SILENCE, - Constants.WARN_ADM_PLAYOUT_ABNORMAL_FREQUENCY, - Constants.WARN_ADM_RECORD_ABNORMAL_FREQUENCY, - Constants.WARN_ADM_CALL_INTERRUPTION, - Constants.WARN_ADM_RECORD_AUDIO_LOWLEVEL, - Constants.WARN_ADM_PLAYOUT_AUDIO_LOWLEVEL, - Constants.WARN_ADM_RECORD_IS_OCCUPIED, - Constants.WARN_APM_HOWLING, - Constants.WARN_ADM_GLITCH_STATE, - Constants.WARN_APM_RESIDUAL_ECHO, - }) - @Retention(RetentionPolicy.SOURCE) - public @interface AgoraWarningCode { - } - - @IntDef({ - RtcEngineConfig.AreaCode.AREA_CODE_CN, - RtcEngineConfig.AreaCode.AREA_CODE_NA, - RtcEngineConfig.AreaCode.AREA_CODE_EU, - RtcEngineConfig.AreaCode.AREA_CODE_AS, - RtcEngineConfig.AreaCode.AREA_CODE_JP, - RtcEngineConfig.AreaCode.AREA_CODE_IN, - RtcEngineConfig.AreaCode.AREA_CODE_GLOB, - }) - @Retention(RetentionPolicy.SOURCE) - public @interface AgoraAreaCode { - } - - @IntDef({ - Constants.SUB_STATE_IDLE, - Constants.SUB_STATE_NO_SUBSCRIBED, - Constants.SUB_STATE_SUBSCRIBING, - Constants.SUB_STATE_SUBSCRIBED, - }) - @Retention(RetentionPolicy.SOURCE) - public @interface AgoraStreamSubscribeState { - } - - @IntDef({ - Constants.PUB_STATE_IDLE, - Constants.PUB_STATE_NO_PUBLISHED, - Constants.PUB_STATE_PUBLISHING, - Constants.PUB_STATE_PUBLISHED, - }) - @Retention(RetentionPolicy.SOURCE) - public @interface AgoraStreamPublishState { - } - - @IntDef({ - Constants.RTMP_STREAMING_EVENT_FAILED_LOAD_IMAGE, - }) - @Retention(RetentionPolicy.SOURCE) - public @interface AgoraRtmpStreamingEvent { - } + @IntDef({ + AgoraRtcAppType.NATIVE, + AgoraRtcAppType.COCOS, + AgoraRtcAppType.UNITY, + AgoraRtcAppType.ELECTRON, + AgoraRtcAppType.FLUTTER, + AgoraRtcAppType.UNREAL, + AgoraRtcAppType.XAMARIN, + AgoraRtcAppType.API_CLOUD, + AgoraRtcAppType.REACT_NATIVE, + AgoraRtcAppType.PYTHON, + AgoraRtcAppType.COCOS_CREATOR, + AgoraRtcAppType.RUST, + AgoraRtcAppType.C_SHARP, + AgoraRtcAppType.CEF, + AgoraRtcAppType.UNI_APP, + }) + @Retention(RetentionPolicy.SOURCE) + public @interface AgoraRtcAppType { + int NATIVE = 0; + int COCOS = 1; + int UNITY = 2; + int ELECTRON = 3; + int FLUTTER = 4; + int UNREAL = 5; + int XAMARIN = 6; + int API_CLOUD = 7; + int REACT_NATIVE = 8; + int PYTHON = 9; + int COCOS_CREATOR = 10; + int RUST = 11; + int C_SHARP = 12; + int CEF = 13; + int UNI_APP = 14; + } + + @IntDef({ + AgoraAudioCodecProfileType.LC_AAC, + AgoraAudioCodecProfileType.HE_AAC, + }) + @Retention(RetentionPolicy.SOURCE) + public @interface AgoraAudioCodecProfileType { + int LC_AAC = 0; + int HE_AAC = 1; + } + + @IntDef({ + Constants.AUDIO_EQUALIZATION_BAND_31, + Constants.AUDIO_EQUALIZATION_BAND_62, + Constants.AUDIO_EQUALIZATION_BAND_125, + Constants.AUDIO_EQUALIZATION_BAND_250, + Constants.AUDIO_EQUALIZATION_BAND_500, + Constants.AUDIO_EQUALIZATION_BAND_1K, + Constants.AUDIO_EQUALIZATION_BAND_2K, + Constants.AUDIO_EQUALIZATION_BAND_4K, + Constants.AUDIO_EQUALIZATION_BAND_8K, + Constants.AUDIO_EQUALIZATION_BAND_16K, + }) + @Retention(RetentionPolicy.SOURCE) + public @interface AgoraAudioEqualizationBandFrequency { + } + + @IntDef({ + Constants.LOCAL_AUDIO_STREAM_ERROR_OK, + Constants.LOCAL_AUDIO_STREAM_ERROR_FAILURE, + Constants.LOCAL_AUDIO_STREAM_ERROR_DEVICE_NO_PERMISSION, + Constants.LOCAL_AUDIO_STREAM_ERROR_DEVICE_BUSY, + Constants.LOCAL_AUDIO_STREAM_ERROR_CAPTURE_FAILURE, + Constants.LOCAL_AUDIO_STREAM_ERROR_ENCODE_FAILURE, + }) + @Retention(RetentionPolicy.SOURCE) + public @interface AgoraAudioLocalError { + } + + @IntDef({ + Constants.LOCAL_AUDIO_STREAM_STATE_STOPPED, + Constants.LOCAL_AUDIO_STREAM_STATE_CAPTURING, + Constants.LOCAL_AUDIO_STREAM_STATE_ENCODING, + Constants.LOCAL_AUDIO_STREAM_STATE_FAILED, + }) + @Retention(RetentionPolicy.SOURCE) + public @interface AgoraAudioLocalState { + } + + @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 { + 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_STOPPED, + Constants.MEDIA_ENGINE_AUDIO_EVENT_MIXING_ERROR, + }) + @Retention(RetentionPolicy.SOURCE) + public @interface AgoraAudioMixingStateCode { + } + + @IntDef({ + Constants.AUDIO_ROUTE_DEFAULT, + Constants.AUDIO_ROUTE_HEADSET, + Constants.AUDIO_ROUTE_EARPIECE, + Constants.AUDIO_ROUTE_HEADSETNOMIC, + Constants.AUDIO_ROUTE_SPEAKERPHONE, + Constants.AUDIO_ROUTE_LOUDSPEAKER, + Constants.AUDIO_ROUTE_HEADSETBLUETOOTH, + }) + @Retention(RetentionPolicy.SOURCE) + public @interface AgoraAudioOutputRouting { + } + + @IntDef({ + Constants.AUDIO_PROFILE_DEFAULT, + Constants.AUDIO_PROFILE_SPEECH_STANDARD, + Constants.AUDIO_PROFILE_MUSIC_STANDARD, + Constants.AUDIO_PROFILE_MUSIC_STANDARD_STEREO, + Constants.AUDIO_PROFILE_MUSIC_HIGH_QUALITY, + Constants.AUDIO_PROFILE_MUSIC_HIGH_QUALITY_STEREO, + }) + @Retention(RetentionPolicy.SOURCE) + public @interface AgoraAudioProfile { + } + + @IntDef({ + Constants.AUDIO_RECORDING_QUALITY_LOW, + Constants.AUDIO_RECORDING_QUALITY_MEDIUM, + Constants.AUDIO_RECORDING_QUALITY_HIGH, + }) + @Retention(RetentionPolicy.SOURCE) + public @interface AgoraAudioRecordingQuality { + } + + @IntDef({ + Constants.REMOTE_AUDIO_STATE_STOPPED, + Constants.REMOTE_AUDIO_STATE_STARTING, + Constants.REMOTE_AUDIO_STATE_DECODING, + Constants.REMOTE_AUDIO_STATE_FROZEN, + Constants.REMOTE_AUDIO_STATE_FAILED, + }) + @Retention(RetentionPolicy.SOURCE) + public @interface AgoraAudioRemoteState { + } + + @IntDef({ + Constants.REMOTE_AUDIO_REASON_INTERNAL, + Constants.REMOTE_AUDIO_REASON_NETWORK_CONGESTION, + Constants.REMOTE_AUDIO_REASON_NETWORK_RECOVERY, + Constants.REMOTE_AUDIO_REASON_LOCAL_MUTED, + Constants.REMOTE_AUDIO_REASON_LOCAL_UNMUTED, + Constants.REMOTE_AUDIO_REASON_REMOTE_MUTED, + Constants.REMOTE_AUDIO_REASON_REMOTE_UNMUTED, + Constants.REMOTE_AUDIO_REASON_REMOTE_OFFLINE, + }) + @Retention(RetentionPolicy.SOURCE) + public @interface AgoraAudioRemoteStateReason { + } + + @IntDef({ + Constants.AUDIO_REVERB_OFF, + Constants.AUDIO_REVERB_POPULAR, + Constants.AUDIO_REVERB_RNB, + Constants.AUDIO_REVERB_ROCK, + Constants.AUDIO_REVERB_HIPHOP, + Constants.AUDIO_REVERB_VOCAL_CONCERT, + Constants.AUDIO_REVERB_KTV, + Constants.AUDIO_REVERB_STUDIO, + Constants.AUDIO_REVERB_FX_KTV, + Constants.AUDIO_REVERB_FX_VOCAL_CONCERT, + Constants.AUDIO_REVERB_FX_UNCLE, + Constants.AUDIO_REVERB_FX_SISTER, + Constants.AUDIO_REVERB_FX_STUDIO, + Constants.AUDIO_REVERB_FX_POPULAR, + Constants.AUDIO_REVERB_FX_RNB, + Constants.AUDIO_REVERB_FX_PHONOGRAPH, + Constants.AUDIO_VIRTUAL_STEREO, + }) + @Retention(RetentionPolicy.SOURCE) + public @interface AgoraAudioReverbPreset { + } + + @IntDef({ + Constants.AUDIO_REVERB_DRY_LEVEL, + Constants.AUDIO_REVERB_WET_LEVEL, + Constants.AUDIO_REVERB_ROOM_SIZE, + Constants.AUDIO_REVERB_WET_DELAY, + Constants.AUDIO_REVERB_STRENGTH, + }) + @Retention(RetentionPolicy.SOURCE) + public @interface AgoraAudioReverbType { + } + + @IntDef({ + AgoraAudioSampleRateType.TYPE_32000, + AgoraAudioSampleRateType.TYPE_44100, + AgoraAudioSampleRateType.TYPE_48000, + }) + @Retention(RetentionPolicy.SOURCE) + public @interface AgoraAudioSampleRateType { + int TYPE_32000 = 32000; + int TYPE_44100 = 44100; + int TYPE_48000 = 48000; + } + + @IntDef({ + Constants.AUDIO_SCENARIO_DEFAULT, + Constants.AUDIO_SCENARIO_CHATROOM_ENTERTAINMENT, + Constants.AUDIO_SCENARIO_EDUCATION, + Constants.AUDIO_SCENARIO_GAME_STREAMING, + Constants.AUDIO_SCENARIO_SHOWROOM, + Constants.AUDIO_SCENARIO_CHATROOM_GAMING, + Constants.AUDIO_SCENARIO_IOT, + Constants.AUDIO_SCENARIO_MEETING, + }) + @Retention(RetentionPolicy.SOURCE) + public @interface AgoraAudioScenario { + } + + @IntDef({ + Constants.VOICE_CHANGER_OFF, + Constants.VOICE_CHANGER_OLDMAN, + Constants.VOICE_CHANGER_BABYBOY, + Constants.VOICE_CHANGER_BABYGIRL, + Constants.VOICE_CHANGER_ZHUBAJIE, + Constants.VOICE_CHANGER_ETHEREAL, + Constants.VOICE_CHANGER_HULK, + Constants.VOICE_BEAUTY_VIGOROUS, + Constants.VOICE_BEAUTY_DEEP, + Constants.VOICE_BEAUTY_MELLOW, + Constants.VOICE_BEAUTY_FALSETTO, + Constants.VOICE_BEAUTY_FULL, + Constants.VOICE_BEAUTY_CLEAR, + Constants.VOICE_BEAUTY_RESOUNDING, + Constants.VOICE_BEAUTY_RINGING, + Constants.VOICE_BEAUTY_SPACIAL, + Constants.GENERAL_BEAUTY_VOICE_MALE_MAGNETIC, + Constants.GENERAL_BEAUTY_VOICE_FEMALE_FRESH, + Constants.GENERAL_BEAUTY_VOICE_FEMALE_VITALITY, + }) + @Retention(RetentionPolicy.SOURCE) + public @interface AgoraAudioVoiceChanger { + } + + @IntDef({ + AgoraCameraCaptureOutputPreference.CAPTURER_OUTPUT_PREFERENCE_AUTO, + AgoraCameraCaptureOutputPreference.CAPTURER_OUTPUT_PREFERENCE_PERFORMANCE, + AgoraCameraCaptureOutputPreference.CAPTURER_OUTPUT_PREFERENCE_PREVIEW, + }) + @Retention(RetentionPolicy.SOURCE) + public @interface AgoraCameraCaptureOutputPreference { + int CAPTURER_OUTPUT_PREFERENCE_AUTO = 0; + int CAPTURER_OUTPUT_PREFERENCE_PERFORMANCE = 1; + int CAPTURER_OUTPUT_PREFERENCE_PREVIEW = 2; + } + + @IntDef({ + AgoraCameraDirection.CAMERA_REAR, + AgoraCameraDirection.CAMERA_FRONT, + }) + @Retention(RetentionPolicy.SOURCE) + public @interface AgoraCameraDirection { + int CAMERA_REAR = 0; + int CAMERA_FRONT = 1; + } + + @IntDef({ + Constants.RELAY_OK, + Constants.RELAY_ERROR_SERVER_ERROR_RESPONSE, + Constants.RELAY_ERROR_SERVER_NO_RESPONSE, + Constants.RELAY_ERROR_NO_RESOURCE_AVAILABLE, + Constants.RELAY_ERROR_FAILED_JOIN_SRC, + Constants.RELAY_ERROR_FAILED_JOIN_DEST, + Constants.RELAY_ERROR_FAILED_PACKET_RECEIVED_FROM_SRC, + Constants.RELAY_ERROR_FAILED_PACKET_SENT_TO_DEST, + Constants.RELAY_ERROR_SERVER_CONNECTION_LOST, + Constants.RELAY_ERROR_INTERNAL_ERROR, + Constants.RELAY_ERROR_SRC_TOKEN_EXPIRED, + Constants.RELAY_ERROR_DEST_TOKEN_EXPIRED, + }) + @Retention(RetentionPolicy.SOURCE) + public @interface AgoraChannelMediaRelayError { + } + + @IntDef({ + Constants.RELAY_EVENT_NETWORK_DISCONNECTED, + Constants.RELAY_EVENT_NETWORK_CONNECTED, + Constants.RELAY_EVENT_PACKET_JOINED_SRC_CHANNEL, + Constants.RELAY_EVENT_PACKET_JOINED_DEST_CHANNEL, + Constants.RELAY_EVENT_PACKET_SENT_TO_DEST_CHANNEL, + Constants.RELAY_EVENT_PACKET_RECEIVED_VIDEO_FROM_SRC, + Constants.RELAY_EVENT_PACKET_RECEIVED_AUDIO_FROM_SRC, + Constants.RELAY_EVENT_PACKET_UPDATE_DEST_CHANNEL, + Constants.RELAY_EVENT_PACKET_UPDATE_DEST_CHANNEL_REFUSED, + Constants.RELAY_EVENT_PACKET_UPDATE_DEST_CHANNEL_NOT_CHANGE, + Constants.RELAY_EVENT_PACKET_UPDATE_DEST_CHANNEL_IS_NULL, + Constants.RELAY_EVENT_VIDEO_PROFILE_UPDATE, + }) + @Retention(RetentionPolicy.SOURCE) + public @interface AgoraChannelMediaRelayEvent { + } + + @IntDef({ + Constants.RELAY_STATE_IDLE, + Constants.RELAY_STATE_CONNECTING, + Constants.RELAY_STATE_RUNNING, + Constants.RELAY_STATE_FAILURE, + }) + @Retention(RetentionPolicy.SOURCE) + public @interface AgoraChannelMediaRelayState { + } + + @IntDef({ + Constants.CHANNEL_PROFILE_COMMUNICATION, + Constants.CHANNEL_PROFILE_LIVE_BROADCASTING, + Constants.CHANNEL_PROFILE_GAME, + }) + @Retention(RetentionPolicy.SOURCE) + public @interface AgoraChannelProfile { + } + + @IntDef({ + Constants.CLIENT_ROLE_BROADCASTER, + Constants.CLIENT_ROLE_AUDIENCE, + }) + @Retention(RetentionPolicy.SOURCE) + public @interface AgoraClientRole { + } + + @IntDef({ + Constants.CONNECTION_CHANGED_CONNECTING, + Constants.CONNECTION_CHANGED_JOIN_SUCCESS, + Constants.CONNECTION_CHANGED_INTERRUPTED, + Constants.CONNECTION_CHANGED_BANNED_BY_SERVER, + Constants.CONNECTION_CHANGED_JOIN_FAILED, + Constants.CONNECTION_CHANGED_LEAVE_CHANNEL, + Constants.CONNECTION_CHANGED_INVALID_APP_ID, + Constants.CONNECTION_CHANGED_INVALID_CHANNEL_NAME, + Constants.CONNECTION_CHANGED_INVALID_TOKEN, + Constants.CONNECTION_CHANGED_TOKEN_EXPIRED, + Constants.CONNECTION_CHANGED_REJECTED_BY_SERVER, + Constants.CONNECTION_CHANGED_SETTING_PROXY_SERVER, + Constants.CONNECTION_CHANGED_RENEW_TOKEN, + Constants.CONNECTION_CHANGED_CLIENT_IP_ADDRESS_CHANGED, + Constants.CONNECTION_CHANGED_KEEP_ALIVE_TIMEOUT, + }) + @Retention(RetentionPolicy.SOURCE) + public @interface AgoraConnectionChangedReason { + } + + @IntDef({ + Constants.CONNECTION_STATE_DISCONNECTED, + Constants.CONNECTION_STATE_CONNECTING, + Constants.CONNECTION_STATE_CONNECTED, + Constants.CONNECTION_STATE_RECONNECTING, + Constants.CONNECTION_STATE_FAILED, + }) + @Retention(RetentionPolicy.SOURCE) + public @interface AgoraConnectionStateType { + } + + @IntDef({ + AgoraDegradationPreference.MAINTAIN_QUALITY, + AgoraDegradationPreference.MAINTAIN_FRAMERATE, + AgoraDegradationPreference.MAINTAIN_BALANCED, + }) + @Retention(RetentionPolicy.SOURCE) + public @interface AgoraDegradationPreference { + int MAINTAIN_QUALITY = 0; + int MAINTAIN_FRAMERATE = 1; + int MAINTAIN_BALANCED = 2; + } + + @IntDef({ + AgoraEncryptionMode.NONE, + AgoraEncryptionMode.AES128XTS, + AgoraEncryptionMode.AES128ECB, + AgoraEncryptionMode.AES256XTS, + AgoraEncryptionMode.SM4128ECB, + }) + @Retention(RetentionPolicy.SOURCE) + public @interface AgoraEncryptionMode { + int NONE = 0; + int AES128XTS = 1; + int AES128ECB = 2; + int AES256XTS = 3; + int SM4128ECB = 4; + } + + @IntDef({ + Constants.ERR_OK, + Constants.ERR_FAILED, + Constants.ERR_INVALID_ARGUMENT, + Constants.ERR_NOT_READY, + Constants.ERR_NOT_SUPPORTED, + Constants.ERR_REFUSED, + Constants.ERR_BUFFER_TOO_SMALL, + Constants.ERR_NOT_INITIALIZED, + Constants.ERR_NO_PERMISSION, + Constants.ERR_TIMEDOUT, + Constants.ERR_CANCELED, + Constants.ERR_TOO_OFTEN, + Constants.ERR_BIND_SOCKET, + Constants.ERR_NET_DOWN, + Constants.ERR_NET_NOBUFS, + Constants.ERR_JOIN_CHANNEL_REJECTED, + Constants.ERR_LEAVE_CHANNEL_REJECTED, + Constants.ERR_ALREADY_IN_USE, + Constants.ERR_INVALID_APP_ID, + Constants.ERR_INVALID_CHANNEL_NAME, + Constants.ERR_NO_SERVER_RESOURCES, + Constants.ERR_TOKEN_EXPIRED, + Constants.ERR_INVALID_TOKEN, + Constants.ERR_CONNECTION_INTERRUPTED, + Constants.ERR_CONNECTION_LOST, + Constants.ERR_NOT_IN_CHANNEL, + Constants.ERR_SIZE_TOO_LARGE, + Constants.ERR_BITRATE_LIMIT, + Constants.ERR_TOO_MANY_DATA_STREAMS, + Constants.ERR_DECRYPTION_FAILED, + Constants.ERR_CLIENT_IS_BANNED_BY_SERVER, + Constants.ERR_WATERMARK_PARAM, + Constants.ERR_WATERMARK_PATH, + Constants.ERR_WATERMARK_PNG, + Constants.ERR_WATERMARKR_INFO, + Constants.ERR_WATERMARK_ARGB, + Constants.ERR_WATERMARK_READ, + Constants.ERR_ENCRYPTED_STREAM_NOT_ALLOWED_PUBLISHED, + Constants.ERR_INVALID_USER_ACCOUNT, + Constants.ERR_PUBLISH_STREAM_CDN_ERROR, + Constants.ERR_PUBLISH_STREAM_NUM_REACH_LIMIT, + Constants.ERR_PUBLISH_STREAM_NOT_AUTHORIZED, + Constants.ERR_PUBLISH_STREAM_INTERNAL_SERVER_ERROR, + Constants.ERR_PUBLISH_STREAM_NOT_FOUND, + Constants.ERR_PUBLISH_STREAM_FORMAT_NOT_SUPPORTED, + Constants.ERR_LOAD_MEDIA_ENGINE, + Constants.ERR_START_CALL, + Constants.ERR_START_CAMERA, + Constants.ERR_START_VIDEO_RENDER, + Constants.ERR_ADM_GENERAL_ERROR, + Constants.ERR_ADM_JAVA_RESOURCE, + Constants.ERR_ADM_SAMPLE_RATE, + Constants.ERR_ADM_INIT_PLAYOUT, + Constants.ERR_ADM_START_PLAYOUT, + Constants.ERR_ADM_STOP_PLAYOUT, + Constants.ERR_ADM_INIT_RECORDING, + Constants.ERR_ADM_START_RECORDING, + Constants.ERR_ADM_STOP_RECORDING, + Constants.ERR_ADM_RUNTIME_PLAYOUT_ERROR, + Constants.ERR_ADM_RUNTIME_RECORDING_ERROR, + Constants.ERR_ADM_RECORD_AUDIO_FAILED, + Constants.ERR_ADM_INIT_LOOPBACK, + Constants.ERR_ADM_START_LOOPBACK, + Constants.ERR_AUDIO_BT_SCO_FAILED, + Constants.ERR_ADM_NO_RECORDING_DEVICE, + Constants.ERR_ADM_NO_PLAYOUT_DEVICE, + Constants.ERR_VDM_CAMERA_NOT_AUTHORIZED, + Constants.ERR_VCM_UNKNOWN_ERROR, + Constants.ERR_VCM_ENCODER_INIT_ERROR, + Constants.ERR_VCM_ENCODER_ENCODE_ERROR, + Constants.ERR_VCM_ENCODER_SET_ERROR, + }) + @Retention(RetentionPolicy.SOURCE) + public @interface AgoraErrorCode { + } + + @IntDef({ + Constants.INJECT_STREAM_STATUS_START_SUCCESS, + Constants.INJECT_STREAM_STATUS_START_ALREADY_EXISTS, + Constants.INJECT_STREAM_STATUS_START_UNAUTHORIZED, + Constants.INJECT_STREAM_STATUS_START_TIMEDOUT, + Constants.INJECT_STREAM_STATUS_START_FAILED, + Constants.INJECT_STREAM_STATUS_STOP_SUCCESS, + Constants.INJECT_STREAM_STATUS_STOP_NOT_FOUND, + Constants.INJECT_STREAM_STATUS_STOP_UNAUTHORIZED, + Constants.INJECT_STREAM_STATUS_STOP_TIMEDOUT, + Constants.INJECT_STREAM_STATUS_STOP_FAILED, + Constants.INJECT_STREAM_STATUS_BROKEN, + }) + @Retention(RetentionPolicy.SOURCE) + public @interface AgoraInjectStreamStatus { + } + + @IntDef({ + Constants.LASTMILE_PROBE_RESULT_COMPLETE, + Constants.LASTMILE_PROBE_RESULT_INCOMPLETE_NO_BWE, + Constants.LASTMILE_PROBE_RESULT_UNAVAILABLE, + }) + @Retention(RetentionPolicy.SOURCE) + public @interface AgoraLastmileProbeResultState { + } + + @IntDef({ + BeautyOptions.LIGHTENING_CONTRAST_LOW, + BeautyOptions.LIGHTENING_CONTRAST_NORMAL, + BeautyOptions.LIGHTENING_CONTRAST_HIGH, + }) + @Retention(RetentionPolicy.SOURCE) + public @interface AgoraLighteningContrastLevel { + } + + @IntDef({ + Constants.LOCAL_VIDEO_STREAM_ERROR_OK, + Constants.LOCAL_VIDEO_STREAM_ERROR_FAILURE, + Constants.LOCAL_VIDEO_STREAM_ERROR_DEVICE_NO_PERMISSION, + Constants.LOCAL_VIDEO_STREAM_ERROR_DEVICE_BUSY, + Constants.LOCAL_VIDEO_STREAM_ERROR_CAPTURE_FAILURE, + Constants.LOCAL_VIDEO_STREAM_ERROR_ENCODE_FAILURE, + }) + @Retention(RetentionPolicy.SOURCE) + public @interface AgoraLocalVideoStreamError { + } + + @IntDef({ + Constants.LOCAL_VIDEO_STREAM_STATE_STOPPED, + Constants.LOCAL_VIDEO_STREAM_STATE_CAPTURING, + Constants.LOCAL_VIDEO_STREAM_STATE_ENCODING, + Constants.LOCAL_VIDEO_STREAM_STATE_FAILED, + }) + @Retention(RetentionPolicy.SOURCE) + public @interface AgoraLocalVideoStreamState { + } + + @IntDef({ + Constants.LOG_FILTER_OFF, + Constants.LOG_FILTER_DEBUG, + Constants.LOG_FILTER_INFO, + Constants.LOG_FILTER_WARNING, + Constants.LOG_FILTER_ERROR, + Constants.LOG_FILTER_CRITICAL, + }) + @Retention(RetentionPolicy.SOURCE) + public @interface AgoraLogFilter { + } + + @IntDef({ + Constants.QUALITY_UNKNOWN, + Constants.QUALITY_EXCELLENT, + Constants.QUALITY_GOOD, + Constants.QUALITY_POOR, + Constants.QUALITY_BAD, + Constants.QUALITY_VBAD, + Constants.QUALITY_DOWN, + Constants.QUALITY_UNSUPPORTED, + Constants.QUALITY_DETECTING, + }) + @Retention(RetentionPolicy.SOURCE) + public @interface AgoraNetworkQuality { + } + + @IntDef({ + Constants.NETWORK_TYPE_UNKNOWN, + Constants.NETWORK_TYPE_DISCONNECTED, + Constants.NETWORK_TYPE_LAN, + Constants.NETWORK_TYPE_WIFI, + Constants.NETWORK_TYPE_MOBILE_2G, + Constants.NETWORK_TYPE_MOBILE_3G, + Constants.NETWORK_TYPE_MOBILE_4G, + }) + @Retention(RetentionPolicy.SOURCE) + public @interface AgoraNetworkType { + } + + @IntDef({ + Constants.RTMP_STREAM_PUBLISH_ERROR_OK, + Constants.RTMP_STREAM_PUBLISH_ERROR_INVALID_ARGUMENT, + Constants.RTMP_STREAM_PUBLISH_ERROR_ENCRYPTED_STREAM_NOT_ALLOWED, + Constants.RTMP_STREAM_PUBLISH_ERROR_CONNECTION_TIMEOUT, + Constants.RTMP_STREAM_PUBLISH_ERROR_INTERNAL_SERVER_ERROR, + Constants.RTMP_STREAM_PUBLISH_ERROR_RTMP_SERVER_ERROR, + Constants.RTMP_STREAM_PUBLISH_ERROR_TOO_OFTEN, + Constants.RTMP_STREAM_PUBLISH_ERROR_REACH_LIMIT, + Constants.RTMP_STREAM_PUBLISH_ERROR_NOT_AUTHORIZED, + Constants.RTMP_STREAM_PUBLISH_ERROR_STREAM_NOT_FOUND, + Constants.RTMP_STREAM_PUBLISH_ERROR_FORMAT_NOT_SUPPORTED, + }) + @Retention(RetentionPolicy.SOURCE) + public @interface AgoraRtmpStreamingErrorCode { + } + + @IntDef({ + Constants.RTMP_STREAM_PUBLISH_STATE_IDLE, + Constants.RTMP_STREAM_PUBLISH_STATE_CONNECTING, + Constants.RTMP_STREAM_PUBLISH_STATE_RUNNING, + Constants.RTMP_STREAM_PUBLISH_STATE_RECOVERING, + Constants.RTMP_STREAM_PUBLISH_STATE_FAILURE, + }) + @Retention(RetentionPolicy.SOURCE) + public @interface AgoraRtmpStreamingState { + } + + @IntDef({ + Constants.STREAM_FALLBACK_OPTION_DISABLED, + Constants.STREAM_FALLBACK_OPTION_VIDEO_STREAM_LOW, + Constants.STREAM_FALLBACK_OPTION_AUDIO_ONLY, + }) + @Retention(RetentionPolicy.SOURCE) + public @interface AgoraStreamFallbackOptions { + } + + @IntDef({ + Constants.USER_OFFLINE_QUIT, + Constants.USER_OFFLINE_DROPPED, + Constants.USER_OFFLINE_BECOME_AUDIENCE, + }) + @Retention(RetentionPolicy.SOURCE) + public @interface AgoraUserOfflineReason { + } + + @IntDef({ + Constants.USER_PRIORITY_HIGH, + Constants.USER_PRIORITY_NORMAL, + }) + @Retention(RetentionPolicy.SOURCE) + public @interface AgoraUserPriority { + } + + @IntDef({ + AgoraVideoCodecProfileType.BASELINE, + AgoraVideoCodecProfileType.MAIN, + AgoraVideoCodecProfileType.HIGH, + }) + @Retention(RetentionPolicy.SOURCE) + public @interface AgoraVideoCodecProfileType { + int BASELINE = 66; + int MAIN = 77; + int HIGH = 100; + } + + @IntDef({ + AgoraVideoFrameRate.FRAME_RATE_FPS_1, + AgoraVideoFrameRate.FRAME_RATE_FPS_7, + AgoraVideoFrameRate.FRAME_RATE_FPS_10, + AgoraVideoFrameRate.FRAME_RATE_FPS_15, + AgoraVideoFrameRate.FRAME_RATE_FPS_24, + AgoraVideoFrameRate.FRAME_RATE_FPS_30, + }) + @Retention(RetentionPolicy.SOURCE) + public @interface AgoraVideoFrameRate { + int FRAME_RATE_FPS_1 = 1; + int FRAME_RATE_FPS_7 = 7; + int FRAME_RATE_FPS_10 = 10; + int FRAME_RATE_FPS_15 = 15; + int FRAME_RATE_FPS_24 = 24; + int FRAME_RATE_FPS_30 = 30; + } + + @IntDef({ + Constants.VIDEO_MIRROR_MODE_AUTO, + Constants.VIDEO_MIRROR_MODE_ENABLED, + Constants.VIDEO_MIRROR_MODE_DISABLED, + }) + @Retention(RetentionPolicy.SOURCE) + public @interface AgoraVideoMirrorMode { + } + + @IntDef({ + AgoraVideoOutputOrientationMode.ORIENTATION_MODE_ADAPTIVE, + AgoraVideoOutputOrientationMode.ORIENTATION_MODE_FIXED_LANDSCAPE, + AgoraVideoOutputOrientationMode.ORIENTATION_MODE_FIXED_PORTRAIT, + }) + @Retention(RetentionPolicy.SOURCE) + public @interface AgoraVideoOutputOrientationMode { + int ORIENTATION_MODE_ADAPTIVE = 0; + int ORIENTATION_MODE_FIXED_LANDSCAPE = 1; + int ORIENTATION_MODE_FIXED_PORTRAIT = 2; + } + + @IntDef({ + Constants.ADAPT_NONE, + Constants.ADAPT_UP_BANDWIDTH, + Constants.ADAPT_DOWN_BANDWIDTH, + }) + @Retention(RetentionPolicy.SOURCE) + public @interface AgoraVideoQualityAdaptIndication { + } + + @IntDef({ + Constants.REMOTE_VIDEO_STATE_STOPPED, + Constants.REMOTE_VIDEO_STATE_STARTING, + Constants.REMOTE_VIDEO_STATE_DECODING, + Constants.REMOTE_VIDEO_STATE_FROZEN, + Constants.REMOTE_VIDEO_STATE_FAILED, + }) + @Retention(RetentionPolicy.SOURCE) + public @interface AgoraVideoRemoteState { + } + + @IntDef({ + Constants.REMOTE_VIDEO_STATE_REASON_INTERNAL, + Constants.REMOTE_VIDEO_STATE_REASON_NETWORK_CONGESTION, + Constants.REMOTE_VIDEO_STATE_REASON_NETWORK_RECOVERY, + Constants.REMOTE_VIDEO_STATE_REASON_LOCAL_MUTED, + Constants.REMOTE_VIDEO_STATE_REASON_LOCAL_UNMUTED, + Constants.REMOTE_VIDEO_STATE_REASON_REMOTE_MUTED, + Constants.REMOTE_VIDEO_STATE_REASON_REMOTE_UNMUTED, + Constants.REMOTE_VIDEO_STATE_REASON_REMOTE_OFFLINE, + Constants.REMOTE_VIDEO_STATE_REASON_AUDIO_FALLBACK, + Constants.REMOTE_VIDEO_STATE_REASON_AUDIO_FALLBACK_RECOVERY, + }) + @Retention(RetentionPolicy.SOURCE) + public @interface AgoraVideoRemoteStateReason { + } + + @IntDef({ + VideoCanvas.RENDER_MODE_HIDDEN, + VideoCanvas.RENDER_MODE_FIT, + VideoCanvas.RENDER_MODE_ADAPTIVE, + VideoCanvas.RENDER_MODE_FILL, + }) + @Retention(RetentionPolicy.SOURCE) + public @interface AgoraVideoRenderMode { + } + + @IntDef({ + Constants.VIDEO_STREAM_HIGH, + Constants.VIDEO_STREAM_LOW, + }) + @Retention(RetentionPolicy.SOURCE) + public @interface AgoraVideoStreamType { + } + + @IntDef({ + Constants.WARN_INVALID_VIEW, + Constants.WARN_INIT_VIDEO, + Constants.WARN_PENDING, + Constants.WARN_NO_AVAILABLE_CHANNEL, + Constants.WARN_LOOKUP_CHANNEL_TIMEOUT, + Constants.WARN_LOOKUP_CHANNEL_REJECTED, + Constants.WARN_OPEN_CHANNEL_TIMEOUT, + Constants.WARN_OPEN_CHANNEL_REJECTED, + Constants.WARN_SWITCH_LIVE_VIDEO_TIMEOUT, + Constants.WARN_SET_CLIENT_ROLE_TIMEOUT, + Constants.WARN_SET_CLIENT_ROLE_NOT_AUTHORIZED, + Constants.WARN_OPEN_CHANNEL_INVALID_TICKET, + Constants.WARN_OPEN_CHANNEL_TRY_NEXT_VOS, + Constants.WARN_AUDIO_MIXING_OPEN_ERROR, + Constants.WARN_ADM_RUNTIME_PLAYOUT_WARNING, + Constants.WARN_ADM_RUNTIME_RECORDING_WARNING, + Constants.WARN_ADM_RECORD_AUDIO_SILENCE, + Constants.WARN_ADM_PLAYOUT_ABNORMAL_FREQUENCY, + Constants.WARN_ADM_RECORD_ABNORMAL_FREQUENCY, + Constants.WARN_ADM_CALL_INTERRUPTION, + Constants.WARN_ADM_RECORD_AUDIO_LOWLEVEL, + Constants.WARN_ADM_PLAYOUT_AUDIO_LOWLEVEL, + Constants.WARN_ADM_RECORD_IS_OCCUPIED, + Constants.WARN_APM_HOWLING, + Constants.WARN_ADM_GLITCH_STATE, + // TODO(3.3.0) WARN_APM_RESIDUAL_ECHO + Constants.WARN_ADM_IMPROPER_SETTINGS, + Constants.WARN_SUPER_RESOLUTION_STREAM_OVER_LIMITATION, + Constants.WARN_SUPER_RESOLUTION_USER_COUNT_OVER_LIMITATION, + Constants.WARN_SUPER_RESOLUTION_DEVICE_NOT_SUPPORTED, + }) + @Retention(RetentionPolicy.SOURCE) + public @interface AgoraWarningCode { + } + + @IntDef({ + RtcEngineConfig.AreaCode.AREA_CODE_CN, + RtcEngineConfig.AreaCode.AREA_CODE_NA, + RtcEngineConfig.AreaCode.AREA_CODE_EU, + RtcEngineConfig.AreaCode.AREA_CODE_AS, + RtcEngineConfig.AreaCode.AREA_CODE_JP, + RtcEngineConfig.AreaCode.AREA_CODE_IN, + RtcEngineConfig.AreaCode.AREA_CODE_GLOB, + }) + @Retention(RetentionPolicy.SOURCE) + public @interface AgoraAreaCode { + } + + @IntDef({ + Constants.SUB_STATE_IDLE, + Constants.SUB_STATE_NO_SUBSCRIBED, + Constants.SUB_STATE_SUBSCRIBING, + Constants.SUB_STATE_SUBSCRIBED, + }) + @Retention(RetentionPolicy.SOURCE) + public @interface AgoraStreamSubscribeState { + } + + @IntDef({ + Constants.PUB_STATE_IDLE, + Constants.PUB_STATE_NO_PUBLISHED, + Constants.PUB_STATE_PUBLISHING, + Constants.PUB_STATE_PUBLISHED, + }) + @Retention(RetentionPolicy.SOURCE) + public @interface AgoraStreamPublishState { + } + + @IntDef({ + Constants.RTMP_STREAMING_EVENT_FAILED_LOAD_IMAGE, + }) + @Retention(RetentionPolicy.SOURCE) + public @interface AgoraRtmpStreamingEvent { + } + + @IntDef({ + Constants.AUDIO_EFFECT_OFF, + Constants.ROOM_ACOUSTICS_KTV, + Constants.ROOM_ACOUSTICS_VOCAL_CONCERT, + Constants.ROOM_ACOUSTICS_STUDIO, + Constants.ROOM_ACOUSTICS_PHONOGRAPH, + Constants.ROOM_ACOUSTICS_VIRTUAL_STEREO, + Constants.ROOM_ACOUSTICS_SPACIAL, + Constants.ROOM_ACOUSTICS_ETHEREAL, + Constants.ROOM_ACOUSTICS_3D_VOICE, + Constants.VOICE_CHANGER_EFFECT_UNCLE, + Constants.VOICE_CHANGER_EFFECT_OLDMAN, + Constants.VOICE_CHANGER_EFFECT_BOY, + Constants.VOICE_CHANGER_EFFECT_SISTER, + Constants.VOICE_CHANGER_EFFECT_GIRL, + Constants.VOICE_CHANGER_EFFECT_PIGKING, + Constants.VOICE_CHANGER_EFFECT_HULK, + Constants.STYLE_TRANSFORMATION_RNB, + Constants.STYLE_TRANSFORMATION_POPULAR, + Constants.PITCH_CORRECTION, + }) + @Retention(RetentionPolicy.SOURCE) + public @interface AgoraAudioEffectPreset { + } + + @IntDef({ + Constants.VOICE_BEAUTIFIER_OFF, + Constants.CHAT_BEAUTIFIER_MAGNETIC, + Constants.CHAT_BEAUTIFIER_FRESH, + Constants.CHAT_BEAUTIFIER_VITALITY, + Constants.TIMBRE_TRANSFORMATION_VIGOROUS, + Constants.TIMBRE_TRANSFORMATION_DEEP, + Constants.TIMBRE_TRANSFORMATION_MELLOW, + Constants.TIMBRE_TRANSFORMATION_FALSETTO, + Constants.TIMBRE_TRANSFORMATION_FULL, + Constants.TIMBRE_TRANSFORMATION_CLEAR, + Constants.TIMBRE_TRANSFORMATION_RESOUNDING, + Constants.TIMBRE_TRANSFORMATION_RINGING, + }) + @Retention(RetentionPolicy.SOURCE) + public @interface AgoraVoiceBeautifierPreset { + } } diff --git a/BeanCovertor.kt b/BeanCovertor.kt index bd346c5e1..d7a94fb9a 100644 --- a/BeanCovertor.kt +++ b/BeanCovertor.kt @@ -10,170 +10,170 @@ import io.agora.rtc.models.ChannelMediaOptions import io.agora.rtc.video.* fun mapToVideoDimensions(map: Map<*, *>): VideoEncoderConfiguration.VideoDimensions { - return VideoEncoderConfiguration.VideoDimensions().apply { - (map["width"] as? Number)?.let { width = it.toInt() } - (map["height"] as? Number)?.let { height = it.toInt() } - } + return VideoEncoderConfiguration.VideoDimensions().apply { + (map["width"] as? Number)?.let { width = it.toInt() } + (map["height"] as? Number)?.let { height = it.toInt() } + } } fun mapToVideoEncoderConfiguration(map: Map<*, *>): VideoEncoderConfiguration { - return VideoEncoderConfiguration().apply { - (map["dimensions"] as? Map<*, *>)?.let { dimensions = mapToVideoDimensions(it) } - (map["frameRate"] as? Number)?.let { frameRate = it.toInt() } - (map["minFrameRate"] as? Number)?.let { minFrameRate = it.toInt() } - (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["mirrorMode"] as? Number)?.let { mirrorMode = it.toInt() } - } + return VideoEncoderConfiguration().apply { + (map["dimensions"] as? Map<*, *>)?.let { dimensions = mapToVideoDimensions(it) } + (map["frameRate"] as? Number)?.let { frameRate = it.toInt() } + (map["minFrameRate"] as? Number)?.let { minFrameRate = it.toInt() } + (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["mirrorMode"] as? Number)?.let { mirrorMode = it.toInt() } + } } fun mapToBeautyOptions(map: Map<*, *>): BeautyOptions { - return BeautyOptions().apply { - (map["lighteningContrastLevel"] as? Number)?.let { lighteningContrastLevel = it.toInt() } - (map["lighteningLevel"] as? Number)?.let { lighteningLevel = it.toFloat() } - (map["smoothnessLevel"] as? Number)?.let { smoothnessLevel = it.toFloat() } - (map["rednessLevel"] as? Number)?.let { rednessLevel = it.toFloat() } - } + return BeautyOptions().apply { + (map["lighteningContrastLevel"] as? Number)?.let { lighteningContrastLevel = it.toInt() } + (map["lighteningLevel"] as? Number)?.let { lighteningLevel = it.toFloat() } + (map["smoothnessLevel"] as? Number)?.let { smoothnessLevel = it.toFloat() } + (map["rednessLevel"] as? Number)?.let { rednessLevel = it.toFloat() } + } } fun mapToAgoraImage(map: Map<*, *>): AgoraImage { - return AgoraImage().apply { - (map["url"] as? String)?.let { url = it } - (map["x"] as? Number)?.let { x = it.toInt() } - (map["y"] as? Number)?.let { y = it.toInt() } - (map["width"] as? Number)?.let { width = it.toInt() } - (map["height"] as? Number)?.let { height = it.toInt() } - } + return AgoraImage().apply { + (map["url"] as? String)?.let { url = it } + (map["x"] as? Number)?.let { x = it.toInt() } + (map["y"] as? Number)?.let { y = it.toInt() } + (map["width"] as? Number)?.let { width = it.toInt() } + (map["height"] as? Number)?.let { height = it.toInt() } + } } fun mapToTranscodingUser(map: Map<*, *>): TranscodingUser { - return TranscodingUser().apply { - (map["uid"] as? Number)?.let { uid = it.toInt() } - (map["x"] as? Number)?.let { x = it.toInt() } - (map["y"] as? Number)?.let { y = it.toInt() } - (map["width"] as? Number)?.let { width = it.toInt() } - (map["height"] as? Number)?.let { height = it.toInt() } - (map["zOrder"] as? Number)?.let { zOrder = it.toInt() } - (map["alpha"] as? Number)?.let { alpha = it.toFloat() } - (map["audioChannel"] as? Number)?.let { audioChannel = it.toInt() } - } + return TranscodingUser().apply { + (map["uid"] as? Number)?.let { uid = it.toInt() } + (map["x"] as? Number)?.let { x = it.toInt() } + (map["y"] as? Number)?.let { y = it.toInt() } + (map["width"] as? Number)?.let { width = it.toInt() } + (map["height"] as? Number)?.let { height = it.toInt() } + (map["zOrder"] as? Number)?.let { zOrder = it.toInt() } + (map["alpha"] as? Number)?.let { alpha = it.toFloat() } + (map["audioChannel"] as? Number)?.let { audioChannel = it.toInt() } + } } fun mapToColor(map: Map<*, *>): Int { - return Color.rgb( - (map["red"] as Number).toInt(), - (map["green"] as Number).toInt(), - (map["blue"] as Number).toInt() - ) + return Color.rgb( + (map["red"] as Number).toInt(), + (map["green"] as Number).toInt(), + (map["blue"] as Number).toInt() + ) } fun mapToLiveTranscoding(map: Map<*, *>): LiveTranscoding { - return LiveTranscoding().apply { - (map["width"] as? Number)?.let { width = it.toInt() } - (map["height"] as? Number)?.let { height = it.toInt() } - (map["videoBitrate"] as? Number)?.let { videoBitrate = it.toInt() } - (map["videoFramerate"] as? Number)?.let { videoFramerate = it.toInt() } - (map["lowLatency"] as? Boolean)?.let { lowLatency = it } - (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["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["backgroundColor"] as? Map<*, *>)?.let { backgroundColor = mapToColor(it) } - (map["userConfigExtraInfo"] as? String)?.let { userConfigExtraInfo = it } - (map["transcodingUsers"] as? List<*>)?.let { list -> - list.forEach { item -> - (item as? Map<*, *>)?.let { - addUser(mapToTranscodingUser(it)) - } - } + return LiveTranscoding().apply { + (map["width"] as? Number)?.let { width = it.toInt() } + (map["height"] as? Number)?.let { height = it.toInt() } + (map["videoBitrate"] as? Number)?.let { videoBitrate = it.toInt() } + (map["videoFramerate"] as? Number)?.let { videoFramerate = it.toInt() } + (map["lowLatency"] as? Boolean)?.let { lowLatency = it } + (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["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["backgroundColor"] as? Map<*, *>)?.let { backgroundColor = mapToColor(it) } + (map["userConfigExtraInfo"] as? String)?.let { userConfigExtraInfo = it } + (map["transcodingUsers"] as? List<*>)?.let { list -> + list.forEach { item -> + (item as? Map<*, *>)?.let { + addUser(mapToTranscodingUser(it)) } + } } + } } fun mapToChannelMediaInfo(map: Map<*, *>): ChannelMediaInfo { - return ChannelMediaInfo( - map["channelName"] as? String, - map["token"] as? String, - (map["uid"] as Number).toInt() - ) + return ChannelMediaInfo( + map["channelName"] as? String, + map["token"] as? String, + (map["uid"] as Number).toInt() + ) } fun mapToChannelMediaRelayConfiguration(map: Map<*, *>): ChannelMediaRelayConfiguration { - return ChannelMediaRelayConfiguration().apply { - (map["srcInfo"] as? Map<*, *>)?.let { setSrcChannelInfo(mapToChannelMediaInfo(it)) } - (map["destInfos"] as? List<*>)?.let { list -> - list.forEach { item -> - (item as? Map<*, *>)?.let { - val info = mapToChannelMediaInfo(it) - setDestChannelInfo(info.channelName, info) - } - } + return ChannelMediaRelayConfiguration().apply { + (map["srcInfo"] as? Map<*, *>)?.let { setSrcChannelInfo(mapToChannelMediaInfo(it)) } + (map["destInfos"] as? List<*>)?.let { list -> + list.forEach { item -> + (item as? Map<*, *>)?.let { + val info = mapToChannelMediaInfo(it) + setDestChannelInfo(info.channelName, info) } + } } + } } fun mapToLastmileProbeConfig(map: Map<*, *>): LastmileProbeConfig { - return LastmileProbeConfig().apply { - (map["probeUplink"] as? Boolean)?.let { probeUplink = it } - (map["probeDownlink"] as? Boolean)?.let { probeDownlink = it } - (map["expectedUplinkBitrate"] as? Number)?.let { expectedUplinkBitrate = it.toInt() } - (map["expectedDownlinkBitrate"] as? Number)?.let { expectedUplinkBitrate = it.toInt() } - } + return LastmileProbeConfig().apply { + (map["probeUplink"] as? Boolean)?.let { probeUplink = it } + (map["probeDownlink"] as? Boolean)?.let { probeDownlink = it } + (map["expectedUplinkBitrate"] as? Number)?.let { expectedUplinkBitrate = it.toInt() } + (map["expectedDownlinkBitrate"] as? Number)?.let { expectedUplinkBitrate = it.toInt() } + } } fun mapToRectangle(map: Map<*, *>): WatermarkOptions.Rectangle { - return WatermarkOptions.Rectangle().apply { - (map["x"] as? Number)?.let { x = it.toInt() } - (map["y"] as? Number)?.let { y = it.toInt() } - (map["width"] as? Number)?.let { width = it.toInt() } - (map["height"] as? Number)?.let { height = it.toInt() } - } + return WatermarkOptions.Rectangle().apply { + (map["x"] as? Number)?.let { x = it.toInt() } + (map["y"] as? Number)?.let { y = it.toInt() } + (map["width"] as? Number)?.let { width = it.toInt() } + (map["height"] as? Number)?.let { height = it.toInt() } + } } 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) } - } + 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) } + } } fun mapToLiveInjectStreamConfig(map: Map<*, *>): LiveInjectStreamConfig { - return LiveInjectStreamConfig().apply { - (map["width"] as? Number)?.let { width = it.toInt() } - (map["height"] as? Number)?.let { height = it.toInt() } - (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["audioBitrate"] as? Number)?.let { audioBitrate = it.toInt() } - (map["audioChannels"] as? Number)?.let { audioChannels = it.toInt() } - } + return LiveInjectStreamConfig().apply { + (map["width"] as? Number)?.let { width = it.toInt() } + (map["height"] as? Number)?.let { height = it.toInt() } + (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["audioBitrate"] as? Number)?.let { audioBitrate = it.toInt() } + (map["audioChannels"] as? Number)?.let { audioChannels = it.toInt() } + } } fun mapToCameraCapturerConfiguration(map: Map<*, *>): CameraCapturerConfiguration { - return CameraCapturerConfiguration( - intToCapturerOutputPreference((map["preference"] as Number).toInt()), - intToCameraDirection((map["cameraDirection"] as Number).toInt()) - ) + return CameraCapturerConfiguration( + intToCapturerOutputPreference((map["preference"] as Number).toInt()), + intToCameraDirection((map["cameraDirection"] as Number).toInt()) + ) } fun mapToChannelMediaOptions(map: Map<*, *>): ChannelMediaOptions { - return ChannelMediaOptions().apply { - (map["autoSubscribeAudio"] as? Boolean)?.let { autoSubscribeAudio = it } - (map["autoSubscribeVideo"] as? Boolean)?.let { autoSubscribeVideo = it } - } + return ChannelMediaOptions().apply { + (map["autoSubscribeAudio"] as? Boolean)?.let { autoSubscribeAudio = it } + (map["autoSubscribeVideo"] as? Boolean)?.let { autoSubscribeVideo = it } + } } fun mapToEncryptionConfig(map: Map<*, *>): EncryptionConfig { - return EncryptionConfig().apply { - (map["encryptionMode"] as? Number)?.let { encryptionMode = intToEncryptionMode(it.toInt()) } - (map["encryptionKey"] as? String)?.let { encryptionKey = it } - } + return EncryptionConfig().apply { + (map["encryptionMode"] as? Number)?.let { encryptionMode = intToEncryptionMode(it.toInt()) } + (map["encryptionKey"] as? String)?.let { encryptionKey = it } + } } diff --git a/Callback.kt b/Callback.kt index 3394d8303..d2dd152c1 100644 --- a/Callback.kt +++ b/Callback.kt @@ -5,37 +5,37 @@ import io.agora.rtc.RtcEngine import kotlin.math.abs abstract class Callback { - fun code(code: Int?, runnable: ((Int) -> Any?)? = null) { - if (code == null || code < 0) { - val newCode = abs(code ?: Constants.ERR_NOT_INITIALIZED) - failure(newCode.toString(), RtcEngine.getErrorDescription(newCode)) - return - } + fun code(code: Int?, runnable: ((Int) -> Any?)? = null) { + if (code == null || code < 0) { + val newCode = abs(code ?: Constants.ERR_NOT_INITIALIZED) + failure(newCode.toString(), RtcEngine.getErrorDescription(newCode)) + return + } - val res = if (runnable != null) runnable(code) else Unit - if (res is Unit) { - success(null) - } else { - success(res) - } + val res = if (runnable != null) runnable(code) else Unit + if (res is Unit) { + success(null) + } else { + success(res) } + } - fun resolve(source: T?, runnable: (T) -> Any?) { - if (source == null) { - val code = Constants.ERR_NOT_INITIALIZED - failure(code.toString(), RtcEngine.getErrorDescription(code)) - return - } + fun resolve(source: T?, runnable: (T) -> Any?) { + if (source == null) { + val code = Constants.ERR_NOT_INITIALIZED + failure(code.toString(), RtcEngine.getErrorDescription(code)) + return + } - val res = runnable(source) - if (res is Unit) { - success(null) - } else { - success(res) - } + val res = runnable(source) + if (res is Unit) { + success(null) + } else { + success(res) } + } - abstract fun success(data: Any?) + abstract fun success(data: Any?) - abstract fun failure(code: String, message: String) + abstract fun failure(code: String, message: String) } diff --git a/EnumCovertor.kt b/EnumCovertor.kt index a6306629c..ea423ce69 100644 --- a/EnumCovertor.kt +++ b/EnumCovertor.kt @@ -7,91 +7,91 @@ import io.agora.rtc.video.CameraCapturerConfiguration import io.agora.rtc.video.VideoEncoderConfiguration fun intToFrameRate(@Annotations.AgoraVideoFrameRate intValue: Int): VideoEncoderConfiguration.FRAME_RATE { - for (value in VideoEncoderConfiguration.FRAME_RATE.values()) { - if (value.value == intValue) { - return value - } + for (value in VideoEncoderConfiguration.FRAME_RATE.values()) { + if (value.value == intValue) { + return value } - throw RuntimeException("VideoEncoderConfiguration.FRAME_RATE not contains $intValue") + } + throw RuntimeException("VideoEncoderConfiguration.FRAME_RATE not contains $intValue") } fun intToOrientationMode(@Annotations.AgoraVideoOutputOrientationMode intValue: Int): VideoEncoderConfiguration.ORIENTATION_MODE { - for (value in VideoEncoderConfiguration.ORIENTATION_MODE.values()) { - if (value.value == intValue) { - return value - } + for (value in VideoEncoderConfiguration.ORIENTATION_MODE.values()) { + if (value.value == intValue) { + return value } - throw RuntimeException("VideoEncoderConfiguration.ORIENTATION_MODE not contains $intValue") + } + throw RuntimeException("VideoEncoderConfiguration.ORIENTATION_MODE not contains $intValue") } fun intToDegradationPreference(@Annotations.AgoraDegradationPreference intValue: Int): VideoEncoderConfiguration.DEGRADATION_PREFERENCE { - for (value in VideoEncoderConfiguration.DEGRADATION_PREFERENCE.values()) { - if (value.value == intValue) { - return value - } + for (value in VideoEncoderConfiguration.DEGRADATION_PREFERENCE.values()) { + if (value.value == intValue) { + return value } - throw RuntimeException("VideoEncoderConfiguration.DEGRADATION_PREFERENCE not contains $intValue") + } + throw RuntimeException("VideoEncoderConfiguration.DEGRADATION_PREFERENCE not contains $intValue") } fun intToLiveTranscodingAudioSampleRate(@Annotations.AgoraAudioSampleRateType intValue: Int): LiveTranscoding.AudioSampleRateType { - for (value in LiveTranscoding.AudioSampleRateType.values()) { - if (LiveTranscoding.AudioSampleRateType.getValue(value) == intValue) { - return value - } + for (value in LiveTranscoding.AudioSampleRateType.values()) { + if (LiveTranscoding.AudioSampleRateType.getValue(value) == intValue) { + return value } - throw RuntimeException("LiveTranscoding.AudioSampleRateType not contains $intValue") + } + throw RuntimeException("LiveTranscoding.AudioSampleRateType not contains $intValue") } fun intToLiveInjectStreamConfigAudioSampleRate(@Annotations.AgoraAudioSampleRateType intValue: Int): LiveInjectStreamConfig.AudioSampleRateType { - for (value in LiveInjectStreamConfig.AudioSampleRateType.values()) { - if (LiveInjectStreamConfig.AudioSampleRateType.getValue(value) == intValue) { - return value - } + for (value in LiveInjectStreamConfig.AudioSampleRateType.values()) { + if (LiveInjectStreamConfig.AudioSampleRateType.getValue(value) == intValue) { + return value } - throw RuntimeException("LiveInjectStreamConfig.AudioSampleRateType not contains $intValue") + } + throw RuntimeException("LiveInjectStreamConfig.AudioSampleRateType not contains $intValue") } fun intToAudioCodecProfile(@Annotations.AgoraAudioCodecProfileType intValue: Int): LiveTranscoding.AudioCodecProfileType { - for (value in LiveTranscoding.AudioCodecProfileType.values()) { - if (LiveTranscoding.AudioCodecProfileType.getValue(value) == intValue) { - return value - } + for (value in LiveTranscoding.AudioCodecProfileType.values()) { + if (LiveTranscoding.AudioCodecProfileType.getValue(value) == intValue) { + return value } - throw RuntimeException("LiveTranscoding.AudioCodecProfileType not contains $intValue") + } + throw RuntimeException("LiveTranscoding.AudioCodecProfileType not contains $intValue") } fun intToVideoCodecProfile(@Annotations.AgoraVideoCodecProfileType intValue: Int): LiveTranscoding.VideoCodecProfileType { - for (value in LiveTranscoding.VideoCodecProfileType.values()) { - if (LiveTranscoding.VideoCodecProfileType.getValue(value) == intValue) { - return value - } + for (value in LiveTranscoding.VideoCodecProfileType.values()) { + if (LiveTranscoding.VideoCodecProfileType.getValue(value) == intValue) { + return value } - throw RuntimeException("LiveTranscoding.VideoCodecProfileType not contains $intValue") + } + throw RuntimeException("LiveTranscoding.VideoCodecProfileType not contains $intValue") } fun intToCapturerOutputPreference(@Annotations.AgoraCameraCaptureOutputPreference intValue: Int): CameraCapturerConfiguration.CAPTURER_OUTPUT_PREFERENCE { - for (value in CameraCapturerConfiguration.CAPTURER_OUTPUT_PREFERENCE.values()) { - if (value.value == intValue) { - return value - } + for (value in CameraCapturerConfiguration.CAPTURER_OUTPUT_PREFERENCE.values()) { + if (value.value == intValue) { + return value } - throw RuntimeException("CameraCapturerConfiguration.CAPTURER_OUTPUT_PREFERENCE not contains $intValue") + } + throw RuntimeException("CameraCapturerConfiguration.CAPTURER_OUTPUT_PREFERENCE not contains $intValue") } fun intToCameraDirection(@Annotations.AgoraCameraDirection intValue: Int): CameraCapturerConfiguration.CAMERA_DIRECTION { - for (value in CameraCapturerConfiguration.CAMERA_DIRECTION.values()) { - if (value.value == intValue) { - return value - } + for (value in CameraCapturerConfiguration.CAMERA_DIRECTION.values()) { + if (value.value == intValue) { + return value } - throw RuntimeException("CameraCapturerConfiguration.CAMERA_DIRECTION not contains $intValue") + } + throw RuntimeException("CameraCapturerConfiguration.CAMERA_DIRECTION not contains $intValue") } fun intToEncryptionMode(@Annotations.AgoraEncryptionMode intValue: Int): EncryptionConfig.EncryptionMode { - for (value in EncryptionConfig.EncryptionMode.values()) { - if (value.value == intValue) { - return value - } + for (value in EncryptionConfig.EncryptionMode.values()) { + if (value.value == intValue) { + return value } - throw RuntimeException("EncryptionConfig.EncryptionMode not contains $intValue") + } + throw RuntimeException("EncryptionConfig.EncryptionMode not contains $intValue") } diff --git a/Extensions.kt b/Extensions.kt index b745ddb7c..13d594918 100644 --- a/Extensions.kt +++ b/Extensions.kt @@ -5,152 +5,152 @@ import io.agora.rtc.IRtcEngineEventHandler.* import io.agora.rtc.models.UserInfo fun UserInfo.toMap(): Map { - return hashMapOf( - "uid" to uid, - "userAccount" to userAccount - ) + return hashMapOf( + "uid" to uid, + "userAccount" to userAccount + ) } fun LocalAudioStats.toMap(): Map { - return hashMapOf( - "numChannels" to numChannels, - "sentSampleRate" to sentSampleRate, - "sentBitrate" to sentBitrate, - "txPacketLossRate" to txPacketLossRate - ) + return hashMapOf( + "numChannels" to numChannels, + "sentSampleRate" to sentSampleRate, + "sentBitrate" to sentBitrate, + "txPacketLossRate" to txPacketLossRate + ) } fun RtcStats.toMap(): Map { - return hashMapOf( - "totalDuration" to totalDuration, - "txBytes" to txBytes, - "rxBytes" to rxBytes, - "txAudioBytes" to txAudioBytes, - "txVideoBytes" to txVideoBytes, - "rxAudioBytes" to rxAudioBytes, - "rxVideoBytes" to rxVideoBytes, - "txKBitRate" to txKBitRate, - "rxKBitRate" to rxKBitRate, - "txAudioKBitRate" to txAudioKBitRate, - "rxAudioKBitRate" to rxAudioKBitRate, - "txVideoKBitRate" to txVideoKBitRate, - "rxVideoKBitRate" to rxVideoKBitRate, - "users" to users, - "lastmileDelay" to lastmileDelay, - "txPacketLossRate" to txPacketLossRate, - "rxPacketLossRate" to rxPacketLossRate, - "cpuTotalUsage" to cpuTotalUsage, - "cpuAppUsage" to cpuAppUsage, - "gatewayRtt" to gatewayRtt, - "memoryAppUsageRatio" to memoryAppUsageRatio, - "memoryTotalUsageRatio" to memoryTotalUsageRatio, - "memoryAppUsageInKbytes" to memoryAppUsageInKbytes - ) + return hashMapOf( + "totalDuration" to totalDuration, + "txBytes" to txBytes, + "rxBytes" to rxBytes, + "txAudioBytes" to txAudioBytes, + "txVideoBytes" to txVideoBytes, + "rxAudioBytes" to rxAudioBytes, + "rxVideoBytes" to rxVideoBytes, + "txKBitRate" to txKBitRate, + "rxKBitRate" to rxKBitRate, + "txAudioKBitRate" to txAudioKBitRate, + "rxAudioKBitRate" to rxAudioKBitRate, + "txVideoKBitRate" to txVideoKBitRate, + "rxVideoKBitRate" to rxVideoKBitRate, + "users" to users, + "lastmileDelay" to lastmileDelay, + "txPacketLossRate" to txPacketLossRate, + "rxPacketLossRate" to rxPacketLossRate, + "cpuTotalUsage" to cpuTotalUsage, + "cpuAppUsage" to cpuAppUsage, + "gatewayRtt" to gatewayRtt, + "memoryAppUsageRatio" to memoryAppUsageRatio, + "memoryTotalUsageRatio" to memoryTotalUsageRatio, + "memoryAppUsageInKbytes" to memoryAppUsageInKbytes + ) } fun Rect.toMap(): Map { - return hashMapOf( - "left" to left, - "top" to top, - "right" to right, - "bottom" to bottom - ) + return hashMapOf( + "left" to left, + "top" to top, + "right" to right, + "bottom" to bottom + ) } fun RemoteAudioStats.toMap(): Map { - return hashMapOf( - "uid" to uid, - "quality" to quality, - "networkTransportDelay" to networkTransportDelay, - "jitterBufferDelay" to jitterBufferDelay, - "audioLossRate" to audioLossRate, - "numChannels" to numChannels, - "receivedSampleRate" to receivedSampleRate, - "receivedBitrate" to receivedBitrate, - "totalFrozenTime" to totalFrozenTime, - "frozenRate" to frozenRate, - "totalActiveTime" to totalActiveTime, - "publishDuration" to publishDuration - ) + return hashMapOf( + "uid" to uid, + "quality" to quality, + "networkTransportDelay" to networkTransportDelay, + "jitterBufferDelay" to jitterBufferDelay, + "audioLossRate" to audioLossRate, + "numChannels" to numChannels, + "receivedSampleRate" to receivedSampleRate, + "receivedBitrate" to receivedBitrate, + "totalFrozenTime" to totalFrozenTime, + "frozenRate" to frozenRate, + "totalActiveTime" to totalActiveTime, + "publishDuration" to publishDuration + ) } fun LocalVideoStats.toMap(): Map { - return hashMapOf( - "sentBitrate" to sentBitrate, - "sentFrameRate" to sentFrameRate, - "encoderOutputFrameRate" to encoderOutputFrameRate, - "rendererOutputFrameRate" to rendererOutputFrameRate, - "targetBitrate" to targetBitrate, - "targetFrameRate" to targetFrameRate, - "qualityAdaptIndication" to qualityAdaptIndication, - "encodedBitrate" to encodedBitrate, - "encodedFrameWidth" to encodedFrameWidth, - "encodedFrameHeight" to encodedFrameHeight, - "encodedFrameCount" to encodedFrameCount, - "codecType" to codecType, - "txPacketLossRate" to txPacketLossRate, - "captureFrameRate" to captureFrameRate - ) + return hashMapOf( + "sentBitrate" to sentBitrate, + "sentFrameRate" to sentFrameRate, + "encoderOutputFrameRate" to encoderOutputFrameRate, + "rendererOutputFrameRate" to rendererOutputFrameRate, + "targetBitrate" to targetBitrate, + "targetFrameRate" to targetFrameRate, + "qualityAdaptIndication" to qualityAdaptIndication, + "encodedBitrate" to encodedBitrate, + "encodedFrameWidth" to encodedFrameWidth, + "encodedFrameHeight" to encodedFrameHeight, + "encodedFrameCount" to encodedFrameCount, + "codecType" to codecType, + "txPacketLossRate" to txPacketLossRate, + "captureFrameRate" to captureFrameRate + ) } fun RemoteVideoStats.toMap(): Map { - return hashMapOf( - "uid" to uid, - "delay" to delay, - "width" to width, - "height" to height, - "receivedBitrate" to receivedBitrate, - "decoderOutputFrameRate" to decoderOutputFrameRate, - "rendererOutputFrameRate" to rendererOutputFrameRate, - "packetLossRate" to packetLossRate, - "rxStreamType" to rxStreamType, - "totalFrozenTime" to totalFrozenTime, - "frozenRate" to frozenRate, - "totalActiveTime" to totalActiveTime, - "publishDuration" to publishDuration - ) + return hashMapOf( + "uid" to uid, + "delay" to delay, + "width" to width, + "height" to height, + "receivedBitrate" to receivedBitrate, + "decoderOutputFrameRate" to decoderOutputFrameRate, + "rendererOutputFrameRate" to rendererOutputFrameRate, + "packetLossRate" to packetLossRate, + "rxStreamType" to rxStreamType, + "totalFrozenTime" to totalFrozenTime, + "frozenRate" to frozenRate, + "totalActiveTime" to totalActiveTime, + "publishDuration" to publishDuration + ) } fun AudioVolumeInfo.toMap(): Map { - return hashMapOf( - "uid" to uid, - "volume" to volume, - "vad" to vad, - "channelId" to channelId - ) + return hashMapOf( + "uid" to uid, + "volume" to volume, + "vad" to vad, + "channelId" to channelId + ) } fun Array.toMapList(): List> { - return List(size) { this[it].toMap() } + return List(size) { this[it].toMap() } } fun LastmileProbeResult.LastmileProbeOneWayResult.toMap(): Map { - return hashMapOf( - "packetLossRate" to packetLossRate, - "jitter" to jitter, - "availableBandwidth" to availableBandwidth - ) + return hashMapOf( + "packetLossRate" to packetLossRate, + "jitter" to jitter, + "availableBandwidth" to availableBandwidth + ) } fun LastmileProbeResult.toMap(): Map { - return hashMapOf( - "state" to state, - "rtt" to rtt, - "uplinkReport" to uplinkReport.toMap(), - "downlinkReport" to downlinkReport.toMap() - ) + return hashMapOf( + "state" to state, + "rtt" to rtt, + "uplinkReport" to uplinkReport.toMap(), + "downlinkReport" to downlinkReport.toMap() + ) } fun AgoraFacePositionInfo.toMap(): Map { - return hashMapOf( - "x" to x, - "y" to y, - "width" to width, - "height" to height, - "distance" to distance - ) + return hashMapOf( + "x" to x, + "y" to y, + "width" to width, + "height" to height, + "distance" to distance + ) } fun Array.toMapList(): List> { - return List(size) { this[it].toMap() } + return List(size) { this[it].toMap() } } diff --git a/MediaObserver.kt b/MediaObserver.kt index 729d7e57f..1983ecfc4 100644 --- a/MediaObserver.kt +++ b/MediaObserver.kt @@ -6,35 +6,35 @@ import java.util.* import java.util.concurrent.atomic.AtomicInteger class MediaObserver( - private val emit: (data: Map?) -> Unit + private val emit: (data: Map?) -> Unit ) : IMetadataObserver { - private var maxMetadataSize = AtomicInteger(0) - private var metadataList = Collections.synchronizedList(mutableListOf()) + private var maxMetadataSize = AtomicInteger(0) + private var metadataList = Collections.synchronizedList(mutableListOf()) - fun addMetadata(metadata: String) { - metadataList.add(metadata) - } + fun addMetadata(metadata: String) { + metadataList.add(metadata) + } - fun setMaxMetadataSize(@IntRange(from = 0, to = 1024) size: Int) { - maxMetadataSize.set(size) - } + fun setMaxMetadataSize(@IntRange(from = 0, to = 1024) size: Int) { + maxMetadataSize.set(size) + } - override fun onReadyToSendMetadata(timeStampMs: Long): ByteArray? { - if (metadataList.size > 0) { - return metadataList.removeAt(0).toByteArray() - } - return null + override fun onReadyToSendMetadata(timeStampMs: Long): ByteArray? { + if (metadataList.size > 0) { + return metadataList.removeAt(0).toByteArray() } + return null + } - override fun getMaxMetadataSize(): Int { - return maxMetadataSize.get() - } + override fun getMaxMetadataSize(): Int { + return maxMetadataSize.get() + } - override fun onMetadataReceived(buffer: ByteArray, uid: Int, timeStampMs: Long) { - emit(hashMapOf( - "buffer" to String(buffer), - "uid" to uid, - "timeStampMs" to timeStampMs - )) - } + override fun onMetadataReceived(buffer: ByteArray, uid: Int, timeStampMs: Long) { + emit(hashMapOf( + "buffer" to String(buffer), + "uid" to uid, + "timeStampMs" to timeStampMs + )) + } } diff --git a/RtcChannel.kt b/RtcChannel.kt index 5d270ca0c..58432cee0 100644 --- a/RtcChannel.kt +++ b/RtcChannel.kt @@ -8,323 +8,323 @@ import io.agora.rtc.internal.EncryptionConfig import java.util.* class IRtcChannel { - interface RtcChannelInterface : RtcAudioInterface, RtcVideoInterface, RtcVoicePositionInterface, - RtcPublishStreamInterface, RtcMediaRelayInterface, RtcDualStreamInterface, - RtcFallbackInterface, RtcMediaMetadataInterface, RtcEncryptionInterface, - RtcInjectStreamInterface, RtcStreamMessageInterface { - fun create(params: Map, callback: Callback) + interface RtcChannelInterface : RtcAudioInterface, RtcVideoInterface, RtcVoicePositionInterface, + RtcPublishStreamInterface, RtcMediaRelayInterface, RtcDualStreamInterface, + RtcFallbackInterface, RtcMediaMetadataInterface, RtcEncryptionInterface, + RtcInjectStreamInterface, RtcStreamMessageInterface { + fun create(params: Map, callback: Callback) - fun destroy(params: Map, callback: Callback) + fun destroy(params: Map, callback: Callback) - fun setClientRole(params: Map, callback: Callback) + fun setClientRole(params: Map, callback: Callback) - fun joinChannel(params: Map, callback: Callback) + fun joinChannel(params: Map, callback: Callback) - fun joinChannelWithUserAccount(params: Map, callback: Callback) + fun joinChannelWithUserAccount(params: Map, callback: Callback) - fun leaveChannel(params: Map, callback: Callback) + fun leaveChannel(params: Map, callback: Callback) - fun renewToken(params: Map, callback: Callback) + fun renewToken(params: Map, callback: Callback) - fun getConnectionState(params: Map, callback: Callback) + fun getConnectionState(params: Map, callback: Callback) - fun publish(params: Map, callback: Callback) + fun publish(params: Map, callback: Callback) - fun unpublish(params: Map, callback: Callback) + fun unpublish(params: Map, callback: Callback) - fun getCallId(params: Map, callback: Callback) - } + fun getCallId(params: Map, callback: Callback) + } - interface RtcAudioInterface { - fun adjustUserPlaybackSignalVolume(params: Map, callback: Callback) + interface RtcAudioInterface { + fun adjustUserPlaybackSignalVolume(params: Map, callback: Callback) - fun muteRemoteAudioStream(params: Map, callback: Callback) + fun muteRemoteAudioStream(params: Map, callback: Callback) - fun muteAllRemoteAudioStreams(params: Map, callback: Callback) + fun muteAllRemoteAudioStreams(params: Map, callback: Callback) - fun setDefaultMuteAllRemoteAudioStreams(params: Map, callback: Callback) - } + fun setDefaultMuteAllRemoteAudioStreams(params: Map, callback: Callback) + } - interface RtcVideoInterface { - fun muteRemoteVideoStream(params: Map, callback: Callback) + interface RtcVideoInterface { + fun muteRemoteVideoStream(params: Map, callback: Callback) - fun muteAllRemoteVideoStreams(params: Map, callback: Callback) + fun muteAllRemoteVideoStreams(params: Map, callback: Callback) - fun setDefaultMuteAllRemoteVideoStreams(params: Map, callback: Callback) - } + fun setDefaultMuteAllRemoteVideoStreams(params: Map, callback: Callback) + } - interface RtcVoicePositionInterface { - fun setRemoteVoicePosition(params: Map, callback: Callback) - } + interface RtcVoicePositionInterface { + fun setRemoteVoicePosition(params: Map, callback: Callback) + } - interface RtcPublishStreamInterface { - fun setLiveTranscoding(params: Map, callback: Callback) + interface RtcPublishStreamInterface { + fun setLiveTranscoding(params: Map, callback: Callback) - fun addPublishStreamUrl(params: Map, callback: Callback) + fun addPublishStreamUrl(params: Map, callback: Callback) - fun removePublishStreamUrl(params: Map, callback: Callback) - } + fun removePublishStreamUrl(params: Map, callback: Callback) + } - interface RtcMediaRelayInterface { - fun startChannelMediaRelay(params: Map, callback: Callback) + interface RtcMediaRelayInterface { + fun startChannelMediaRelay(params: Map, callback: Callback) - fun updateChannelMediaRelay(params: Map, callback: Callback) + fun updateChannelMediaRelay(params: Map, callback: Callback) - fun stopChannelMediaRelay(params: Map, callback: Callback) - } + fun stopChannelMediaRelay(params: Map, callback: Callback) + } - interface RtcDualStreamInterface { - fun setRemoteVideoStreamType(params: Map, callback: Callback) + interface RtcDualStreamInterface { + fun setRemoteVideoStreamType(params: Map, callback: Callback) - fun setRemoteDefaultVideoStreamType(params: Map, callback: Callback) - } + fun setRemoteDefaultVideoStreamType(params: Map, callback: Callback) + } - interface RtcFallbackInterface { - fun setRemoteUserPriority(params: Map, callback: Callback) - } + interface RtcFallbackInterface { + fun setRemoteUserPriority(params: Map, callback: Callback) + } - interface RtcMediaMetadataInterface { - fun registerMediaMetadataObserver(params: Map, callback: Callback) + interface RtcMediaMetadataInterface { + fun registerMediaMetadataObserver(params: Map, callback: Callback) - fun unregisterMediaMetadataObserver(params: Map, callback: Callback) + fun unregisterMediaMetadataObserver(params: Map, callback: Callback) - fun setMaxMetadataSize(params: Map, callback: Callback) + fun setMaxMetadataSize(params: Map, callback: Callback) - fun sendMetadata(params: Map, callback: Callback) - } + fun sendMetadata(params: Map, callback: Callback) + } - interface RtcEncryptionInterface { - fun setEncryptionSecret(params: Map, callback: Callback) + interface RtcEncryptionInterface { + fun setEncryptionSecret(params: Map, callback: Callback) - fun setEncryptionMode(params: Map, callback: Callback) + fun setEncryptionMode(params: Map, callback: Callback) - fun enableEncryption(params: Map, callback: Callback) - } + fun enableEncryption(params: Map, callback: Callback) + } - interface RtcInjectStreamInterface { - fun addInjectStreamUrl(params: Map, callback: Callback) + interface RtcInjectStreamInterface { + fun addInjectStreamUrl(params: Map, callback: Callback) - fun removeInjectStreamUrl(params: Map, callback: Callback) - } + fun removeInjectStreamUrl(params: Map, callback: Callback) + } - interface RtcStreamMessageInterface { - fun createDataStream(params: Map, callback: Callback) + interface RtcStreamMessageInterface { + fun createDataStream(params: Map, callback: Callback) - fun sendStreamMessage(params: Map, callback: Callback) - } + fun sendStreamMessage(params: Map, callback: Callback) + } } class RtcChannelManager( - private val emit: (methodName: String, data: Map?) -> Unit + private val emit: (methodName: String, data: Map?) -> Unit ) : IRtcChannel.RtcChannelInterface { - private val rtcChannelMap = Collections.synchronizedMap(mutableMapOf()) - private val mediaObserverMap = Collections.synchronizedMap(mutableMapOf()) - - fun release() { - rtcChannelMap.forEach { it.value.destroy() } - rtcChannelMap.clear() - mediaObserverMap.clear() - } - - operator fun get(channelId: String): RtcChannel? { - return rtcChannelMap[channelId] - } - - override fun create(params: Map, callback: Callback) { - callback.resolve(params["engine"] as RtcEngine) { e -> - e.createRtcChannel(params["channelId"] as String)?.let { - it.setRtcChannelEventHandler(RtcChannelEventHandler { methodName, data -> emit(methodName, data) }) - rtcChannelMap[it.channelId()] = it - } - Unit - } - } - - override fun destroy(params: Map, callback: Callback) { - var code: Int? = -Constants.ERR_NOT_INITIALIZED - this[params["channelId"] as String]?.let { - code = rtcChannelMap.remove(it.channelId())?.destroy() - } - callback.code(code) - } - - override fun setClientRole(params: Map, callback: Callback) { - callback.code(this[params["channelId"] as String]?.setClientRole((params["role"] as Number).toInt())) - } - - override fun joinChannel(params: Map, callback: Callback) { - callback.code(this[params["channelId"] as String]?.joinChannel(params["token"] as? String, params["optionalInfo"] as? String, (params["optionalUid"] as Number).toInt(), mapToChannelMediaOptions(params["options"] as Map<*, *>))) - } - - override fun joinChannelWithUserAccount(params: Map, callback: Callback) { - callback.code(this[params["channelId"] as String]?.joinChannelWithUserAccount(params["token"] as? String, params["userAccount"] as String, mapToChannelMediaOptions(params["options"] as Map<*, *>))) - } - - override fun leaveChannel(params: Map, callback: Callback) { - callback.code(this[params["channelId"] as String]?.leaveChannel()) - } - - override fun renewToken(params: Map, callback: Callback) { - callback.code(this[params["channelId"] as String]?.renewToken(params["token"] as String)) - } - - override fun getConnectionState(params: Map, callback: Callback) { - callback.resolve(this[params["channelId"] as String]) { it.connectionState } - } - - override fun publish(params: Map, callback: Callback) { - callback.code(this[params["channelId"] as String]?.publish()) - } - - override fun unpublish(params: Map, callback: Callback) { - callback.code(this[params["channelId"] as String]?.unpublish()) - } - - override fun getCallId(params: Map, callback: Callback) { - callback.resolve(this[params["channelId"] as String]) { it.callId } - } - - override fun adjustUserPlaybackSignalVolume(params: Map, callback: Callback) { - callback.code(this[params["channelId"] as String]?.adjustUserPlaybackSignalVolume((params["uid"] as Number).toInt(), (params["volume"] as Number).toInt())) - } - - override fun muteRemoteAudioStream(params: Map, callback: Callback) { - callback.code(this[params["channelId"] as String]?.muteRemoteAudioStream((params["uid"] as Number).toInt(), params["muted"] as Boolean)) - } - - override fun muteAllRemoteAudioStreams(params: Map, callback: Callback) { - callback.code(this[params["channelId"] as String]?.muteAllRemoteAudioStreams(params["muted"] as Boolean)) - } - - override fun setDefaultMuteAllRemoteAudioStreams(params: Map, callback: Callback) { - callback.code(this[params["channelId"] as String]?.setDefaultMuteAllRemoteAudioStreams(params["muted"] as Boolean)) - } - - override fun muteRemoteVideoStream(params: Map, callback: Callback) { - callback.code(this[params["channelId"] as String]?.muteRemoteVideoStream((params["uid"] as Number).toInt(), params["muted"] as Boolean)) - } - - override fun muteAllRemoteVideoStreams(params: Map, callback: Callback) { - callback.code(this[params["channelId"] as String]?.muteAllRemoteVideoStreams(params["muted"] as Boolean)) - } - - override fun setDefaultMuteAllRemoteVideoStreams(params: Map, callback: Callback) { - callback.code(this[params["channelId"] as String]?.setDefaultMuteAllRemoteVideoStreams(params["muted"] as Boolean)) - } - - override fun setRemoteVoicePosition(params: Map, callback: Callback) { - callback.code(this[params["channelId"] as String]?.setRemoteVoicePosition((params["uid"] as Number).toInt(), (params["pan"] as Number).toDouble(), (params["gain"] as Number).toDouble())) - } + private val rtcChannelMap = Collections.synchronizedMap(mutableMapOf()) + private val mediaObserverMap = Collections.synchronizedMap(mutableMapOf()) - override fun setLiveTranscoding(params: Map, callback: Callback) { - callback.code(this[params["channelId"] as String]?.setLiveTranscoding(mapToLiveTranscoding(params["transcoding"] as Map<*, *>))) - } + fun release() { + rtcChannelMap.forEach { it.value.destroy() } + rtcChannelMap.clear() + mediaObserverMap.clear() + } + + operator fun get(channelId: String): RtcChannel? { + return rtcChannelMap[channelId] + } + + override fun create(params: Map, callback: Callback) { + callback.resolve(params["engine"] as RtcEngine) { e -> + e.createRtcChannel(params["channelId"] as String)?.let { + it.setRtcChannelEventHandler(RtcChannelEventHandler { methodName, data -> emit(methodName, data) }) + rtcChannelMap[it.channelId()] = it + } + Unit + } + } - override fun addPublishStreamUrl(params: Map, callback: Callback) { - callback.code(this[params["channelId"] as String]?.addPublishStreamUrl(params["url"] as String, params["transcodingEnabled"] as Boolean)) - } + override fun destroy(params: Map, callback: Callback) { + var code: Int? = -Constants.ERR_NOT_INITIALIZED + this[params["channelId"] as String]?.let { + code = rtcChannelMap.remove(it.channelId())?.destroy() + } + callback.code(code) + } - override fun removePublishStreamUrl(params: Map, callback: Callback) { - callback.code(this[params["channelId"] as String]?.removePublishStreamUrl(params["url"] as String)) - } + override fun setClientRole(params: Map, callback: Callback) { + callback.code(this[params["channelId"] as String]?.setClientRole((params["role"] as Number).toInt())) + } - override fun startChannelMediaRelay(params: Map, callback: Callback) { - callback.code(this[params["channelId"] as String]?.startChannelMediaRelay(mapToChannelMediaRelayConfiguration(params["channelMediaRelayConfiguration"] as Map<*, *>))) - } - - override fun updateChannelMediaRelay(params: Map, callback: Callback) { - callback.code(this[params["channelId"] as String]?.updateChannelMediaRelay(mapToChannelMediaRelayConfiguration(params["channelMediaRelayConfiguration"] as Map<*, *>))) - } - - override fun stopChannelMediaRelay(params: Map, callback: Callback) { - callback.code(this[params["channelId"] as String]?.stopChannelMediaRelay()) - } - - override fun setRemoteVideoStreamType(params: Map, callback: Callback) { - callback.code(this[params["channelId"] as String]?.setRemoteVideoStreamType((params["uid"] as Number).toInt(), (params["streamType"] as Number).toInt())) - } - - override fun setRemoteDefaultVideoStreamType(params: Map, callback: Callback) { - callback.code(this[params["channelId"] as String]?.setRemoteDefaultVideoStreamType((params["streamType"] as Number).toInt())) - } - - override fun setRemoteUserPriority(params: Map, callback: Callback) { - callback.code(this[params["channelId"] as String]?.setRemoteUserPriority((params["uid"] as Number).toInt(), (params["userPriority"] as Number).toInt())) - } - - override fun registerMediaMetadataObserver(params: Map, callback: Callback) { - var code = -Constants.ERR_NOT_INITIALIZED - this[params["channelId"] as String]?.let { - val mediaObserver = MediaObserver { data -> - emit(RtcChannelEvents.MetadataReceived, data?.toMutableMap()?.apply { put("channelId", it.channelId()) }) - } - code = it.registerMediaMetadataObserver(mediaObserver, IMetadataObserver.VIDEO_METADATA) - if (code == 0) mediaObserverMap[it.channelId()] = mediaObserver - } - callback.code(code) - } - - override fun unregisterMediaMetadataObserver(params: Map, callback: Callback) { - var code = -Constants.ERR_NOT_INITIALIZED - this[params["channelId"] as String]?.let { - code = it.registerMediaMetadataObserver(null, IMetadataObserver.VIDEO_METADATA) - if (code == 0) mediaObserverMap.remove(it.channelId()) - } - callback.code(code) - } - - override fun setMaxMetadataSize(params: Map, callback: Callback) { - callback.resolve(mediaObserverMap[params["channelId"] as String]) { - it.maxMetadataSize = (params["size"] as Number).toInt() - Unit - } - } - - override fun sendMetadata(params: Map, callback: Callback) { - callback.resolve(mediaObserverMap[params["channelId"] as String]) { - it.addMetadata(params["metadata"] as String) - Unit - } - } - - override fun setEncryptionSecret(params: Map, callback: Callback) { - callback.code(this[params["channelId"] as String]?.setEncryptionSecret(params["secret"] as String)) - } - - override fun setEncryptionMode(params: Map, callback: Callback) { - callback.code(this[params["channelId"] as String]?.setEncryptionMode(when ((params["encryptionMode"] as Number).toInt()) { - EncryptionConfig.EncryptionMode.AES_128_XTS.value -> "aes-128-xts" - EncryptionConfig.EncryptionMode.AES_128_ECB.value -> "aes-128-ecb" - EncryptionConfig.EncryptionMode.AES_256_XTS.value -> "aes-256-xts" - else -> "" - })) - } - - override fun enableEncryption(params: Map, callback: Callback) { - callback.code(this[params["channelId"] as String]?.enableEncryption(params["enabled"] as Boolean, mapToEncryptionConfig(params["config"] as Map<*, *>))) - } - - override fun addInjectStreamUrl(params: Map, callback: Callback) { - callback.code(this[params["channelId"] as String]?.addInjectStreamUrl(params["url"] as String, mapToLiveInjectStreamConfig(params["config"] as Map<*, *>))) - } - - override fun removeInjectStreamUrl(params: Map, callback: Callback) { - callback.code(this[params["channelId"] as String]?.removeInjectStreamUrl(params["url"] as String)) - } - - override fun createDataStream(params: Map, callback: Callback) { - var code = -Constants.ERR_NOT_INITIALIZED - this[params["channelId"] as String]?.let { - code = it.createDataStream(params["reliable"] as Boolean, params["ordered"] as Boolean) - } - callback.code(code) { it } - } - - override fun sendStreamMessage(params: Map, callback: Callback) { - 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) - } + override fun joinChannel(params: Map, callback: Callback) { + callback.code(this[params["channelId"] as String]?.joinChannel(params["token"] as? String, params["optionalInfo"] as? String, (params["optionalUid"] as Number).toInt(), mapToChannelMediaOptions(params["options"] as Map<*, *>))) + } + + override fun joinChannelWithUserAccount(params: Map, callback: Callback) { + callback.code(this[params["channelId"] as String]?.joinChannelWithUserAccount(params["token"] as? String, params["userAccount"] as String, mapToChannelMediaOptions(params["options"] as Map<*, *>))) + } + + override fun leaveChannel(params: Map, callback: Callback) { + callback.code(this[params["channelId"] as String]?.leaveChannel()) + } + + override fun renewToken(params: Map, callback: Callback) { + callback.code(this[params["channelId"] as String]?.renewToken(params["token"] as String)) + } + + override fun getConnectionState(params: Map, callback: Callback) { + callback.resolve(this[params["channelId"] as String]) { it.connectionState } + } + + override fun publish(params: Map, callback: Callback) { + callback.code(this[params["channelId"] as String]?.publish()) + } + + override fun unpublish(params: Map, callback: Callback) { + callback.code(this[params["channelId"] as String]?.unpublish()) + } + + override fun getCallId(params: Map, callback: Callback) { + callback.resolve(this[params["channelId"] as String]) { it.callId } + } + + override fun adjustUserPlaybackSignalVolume(params: Map, callback: Callback) { + callback.code(this[params["channelId"] as String]?.adjustUserPlaybackSignalVolume((params["uid"] as Number).toInt(), (params["volume"] as Number).toInt())) + } + + override fun muteRemoteAudioStream(params: Map, callback: Callback) { + callback.code(this[params["channelId"] as String]?.muteRemoteAudioStream((params["uid"] as Number).toInt(), params["muted"] as Boolean)) + } + + override fun muteAllRemoteAudioStreams(params: Map, callback: Callback) { + callback.code(this[params["channelId"] as String]?.muteAllRemoteAudioStreams(params["muted"] as Boolean)) + } + + override fun setDefaultMuteAllRemoteAudioStreams(params: Map, callback: Callback) { + callback.code(this[params["channelId"] as String]?.setDefaultMuteAllRemoteAudioStreams(params["muted"] as Boolean)) + } + + override fun muteRemoteVideoStream(params: Map, callback: Callback) { + callback.code(this[params["channelId"] as String]?.muteRemoteVideoStream((params["uid"] as Number).toInt(), params["muted"] as Boolean)) + } + + override fun muteAllRemoteVideoStreams(params: Map, callback: Callback) { + callback.code(this[params["channelId"] as String]?.muteAllRemoteVideoStreams(params["muted"] as Boolean)) + } + + override fun setDefaultMuteAllRemoteVideoStreams(params: Map, callback: Callback) { + callback.code(this[params["channelId"] as String]?.setDefaultMuteAllRemoteVideoStreams(params["muted"] as Boolean)) + } + + override fun setRemoteVoicePosition(params: Map, callback: Callback) { + callback.code(this[params["channelId"] as String]?.setRemoteVoicePosition((params["uid"] as Number).toInt(), (params["pan"] as Number).toDouble(), (params["gain"] as Number).toDouble())) + } + + override fun setLiveTranscoding(params: Map, callback: Callback) { + callback.code(this[params["channelId"] as String]?.setLiveTranscoding(mapToLiveTranscoding(params["transcoding"] as Map<*, *>))) + } + + override fun addPublishStreamUrl(params: Map, callback: Callback) { + callback.code(this[params["channelId"] as String]?.addPublishStreamUrl(params["url"] as String, params["transcodingEnabled"] as Boolean)) + } + + override fun removePublishStreamUrl(params: Map, callback: Callback) { + callback.code(this[params["channelId"] as String]?.removePublishStreamUrl(params["url"] as String)) + } + + override fun startChannelMediaRelay(params: Map, callback: Callback) { + callback.code(this[params["channelId"] as String]?.startChannelMediaRelay(mapToChannelMediaRelayConfiguration(params["channelMediaRelayConfiguration"] as Map<*, *>))) + } + + override fun updateChannelMediaRelay(params: Map, callback: Callback) { + callback.code(this[params["channelId"] as String]?.updateChannelMediaRelay(mapToChannelMediaRelayConfiguration(params["channelMediaRelayConfiguration"] as Map<*, *>))) + } + + override fun stopChannelMediaRelay(params: Map, callback: Callback) { + callback.code(this[params["channelId"] as String]?.stopChannelMediaRelay()) + } + + override fun setRemoteVideoStreamType(params: Map, callback: Callback) { + callback.code(this[params["channelId"] as String]?.setRemoteVideoStreamType((params["uid"] as Number).toInt(), (params["streamType"] as Number).toInt())) + } + + override fun setRemoteDefaultVideoStreamType(params: Map, callback: Callback) { + callback.code(this[params["channelId"] as String]?.setRemoteDefaultVideoStreamType((params["streamType"] as Number).toInt())) + } + + override fun setRemoteUserPriority(params: Map, callback: Callback) { + callback.code(this[params["channelId"] as String]?.setRemoteUserPriority((params["uid"] as Number).toInt(), (params["userPriority"] as Number).toInt())) + } + + override fun registerMediaMetadataObserver(params: Map, callback: Callback) { + var code = -Constants.ERR_NOT_INITIALIZED + this[params["channelId"] as String]?.let { + val mediaObserver = MediaObserver { data -> + emit(RtcChannelEvents.MetadataReceived, data?.toMutableMap()?.apply { put("channelId", it.channelId()) }) + } + code = it.registerMediaMetadataObserver(mediaObserver, IMetadataObserver.VIDEO_METADATA) + if (code == 0) mediaObserverMap[it.channelId()] = mediaObserver + } + callback.code(code) + } + + override fun unregisterMediaMetadataObserver(params: Map, callback: Callback) { + var code = -Constants.ERR_NOT_INITIALIZED + this[params["channelId"] as String]?.let { + code = it.registerMediaMetadataObserver(null, IMetadataObserver.VIDEO_METADATA) + if (code == 0) mediaObserverMap.remove(it.channelId()) + } + callback.code(code) + } + + override fun setMaxMetadataSize(params: Map, callback: Callback) { + callback.resolve(mediaObserverMap[params["channelId"] as String]) { + it.maxMetadataSize = (params["size"] as Number).toInt() + Unit + } + } + + override fun sendMetadata(params: Map, callback: Callback) { + callback.resolve(mediaObserverMap[params["channelId"] as String]) { + it.addMetadata(params["metadata"] as String) + Unit + } + } + + override fun setEncryptionSecret(params: Map, callback: Callback) { + callback.code(this[params["channelId"] as String]?.setEncryptionSecret(params["secret"] as String)) + } + + override fun setEncryptionMode(params: Map, callback: Callback) { + callback.code(this[params["channelId"] as String]?.setEncryptionMode(when ((params["encryptionMode"] as Number).toInt()) { + EncryptionConfig.EncryptionMode.AES_128_XTS.value -> "aes-128-xts" + EncryptionConfig.EncryptionMode.AES_128_ECB.value -> "aes-128-ecb" + EncryptionConfig.EncryptionMode.AES_256_XTS.value -> "aes-256-xts" + else -> "" + })) + } + + override fun enableEncryption(params: Map, callback: Callback) { + callback.code(this[params["channelId"] as String]?.enableEncryption(params["enabled"] as Boolean, mapToEncryptionConfig(params["config"] as Map<*, *>))) + } + + override fun addInjectStreamUrl(params: Map, callback: Callback) { + callback.code(this[params["channelId"] as String]?.addInjectStreamUrl(params["url"] as String, mapToLiveInjectStreamConfig(params["config"] as Map<*, *>))) + } + + override fun removeInjectStreamUrl(params: Map, callback: Callback) { + callback.code(this[params["channelId"] as String]?.removeInjectStreamUrl(params["url"] as String)) + } + + override fun createDataStream(params: Map, callback: Callback) { + var code = -Constants.ERR_NOT_INITIALIZED + this[params["channelId"] as String]?.let { + code = it.createDataStream(params["reliable"] as Boolean, params["ordered"] as Boolean) + } + callback.code(code) { it } + } + + override fun sendStreamMessage(params: Map, callback: Callback) { + 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) + } } diff --git a/RtcChannelEvent.kt b/RtcChannelEvent.kt index fe3dca3b0..f00f9a5fa 100644 --- a/RtcChannelEvent.kt +++ b/RtcChannelEvent.kt @@ -6,234 +6,234 @@ import io.agora.rtc.IRtcEngineEventHandler import io.agora.rtc.RtcChannel class RtcChannelEvents { - companion object { - const val Warning = "Warning" - const val Error = "Error" - const val JoinChannelSuccess = "JoinChannelSuccess" - const val RejoinChannelSuccess = "RejoinChannelSuccess" - const val LeaveChannel = "LeaveChannel" - const val ClientRoleChanged = "ClientRoleChanged" - const val UserJoined = "UserJoined" - const val UserOffline = "UserOffline" - const val ConnectionStateChanged = "ConnectionStateChanged" - const val ConnectionLost = "ConnectionLost" - const val TokenPrivilegeWillExpire = "TokenPrivilegeWillExpire" - const val RequestToken = "RequestToken" - const val ActiveSpeaker = "ActiveSpeaker" - const val VideoSizeChanged = "VideoSizeChanged" - const val RemoteVideoStateChanged = "RemoteVideoStateChanged" - const val RemoteAudioStateChanged = "RemoteAudioStateChanged" - const val LocalPublishFallbackToAudioOnly = "LocalPublishFallbackToAudioOnly" - const val RemoteSubscribeFallbackToAudioOnly = "RemoteSubscribeFallbackToAudioOnly" - const val RtcStats = "RtcStats" - const val NetworkQuality = "NetworkQuality" - const val RemoteVideoStats = "RemoteVideoStats" - const val RemoteAudioStats = "RemoteAudioStats" - const val RtmpStreamingStateChanged = "RtmpStreamingStateChanged" - const val TranscodingUpdated = "TranscodingUpdated" - const val StreamInjectedStatus = "StreamInjectedStatus" - const val StreamMessage = "StreamMessage" - const val StreamMessageError = "StreamMessageError" - const val ChannelMediaRelayStateChanged = "ChannelMediaRelayStateChanged" - const val ChannelMediaRelayEvent = "ChannelMediaRelayEvent" - const val MetadataReceived = "MetadataReceived" - const val AudioPublishStateChanged = "AudioPublishStateChanged" - const val VideoPublishStateChanged = "VideoPublishStateChanged" - const val AudioSubscribeStateChanged = "AudioSubscribeStateChanged" - const val VideoSubscribeStateChanged = "VideoSubscribeStateChanged" - const val RtmpStreamingEvent = "RtmpStreamingEvent" - - fun toMap(): Map { - return hashMapOf( - "Warning" to Warning, - "Error" to Error, - "JoinChannelSuccess" to JoinChannelSuccess, - "RejoinChannelSuccess" to RejoinChannelSuccess, - "LeaveChannel" to LeaveChannel, - "ClientRoleChanged" to ClientRoleChanged, - "UserJoined" to UserJoined, - "UserOffline" to UserOffline, - "ConnectionStateChanged" to ConnectionStateChanged, - "ConnectionLost" to ConnectionLost, - "TokenPrivilegeWillExpire" to TokenPrivilegeWillExpire, - "RequestToken" to RequestToken, - "ActiveSpeaker" to ActiveSpeaker, - "VideoSizeChanged" to VideoSizeChanged, - "RemoteVideoStateChanged" to RemoteVideoStateChanged, - "RemoteAudioStateChanged" to RemoteAudioStateChanged, - "LocalPublishFallbackToAudioOnly" to LocalPublishFallbackToAudioOnly, - "RemoteSubscribeFallbackToAudioOnly" to RemoteSubscribeFallbackToAudioOnly, - "RtcStats" to RtcStats, - "NetworkQuality" to NetworkQuality, - "RemoteVideoStats" to RemoteVideoStats, - "RemoteAudioStats" to RemoteAudioStats, - "RtmpStreamingStateChanged" to RtmpStreamingStateChanged, - "TranscodingUpdated" to TranscodingUpdated, - "StreamInjectedStatus" to StreamInjectedStatus, - "StreamMessage" to StreamMessage, - "StreamMessageError" to StreamMessageError, - "ChannelMediaRelayStateChanged" to ChannelMediaRelayStateChanged, - "ChannelMediaRelayEvent" to ChannelMediaRelayEvent, - "MetadataReceived" to MetadataReceived, - "AudioPublishStateChanged" to AudioPublishStateChanged, - "VideoPublishStateChanged" to VideoPublishStateChanged, - "AudioSubscribeStateChanged" to AudioSubscribeStateChanged, - "VideoSubscribeStateChanged" to VideoSubscribeStateChanged, - "RtmpStreamingEvent" to RtmpStreamingEvent - ) - } - } + companion object { + const val Warning = "Warning" + const val Error = "Error" + const val JoinChannelSuccess = "JoinChannelSuccess" + const val RejoinChannelSuccess = "RejoinChannelSuccess" + const val LeaveChannel = "LeaveChannel" + const val ClientRoleChanged = "ClientRoleChanged" + const val UserJoined = "UserJoined" + const val UserOffline = "UserOffline" + const val ConnectionStateChanged = "ConnectionStateChanged" + const val ConnectionLost = "ConnectionLost" + const val TokenPrivilegeWillExpire = "TokenPrivilegeWillExpire" + const val RequestToken = "RequestToken" + const val ActiveSpeaker = "ActiveSpeaker" + const val VideoSizeChanged = "VideoSizeChanged" + const val RemoteVideoStateChanged = "RemoteVideoStateChanged" + const val RemoteAudioStateChanged = "RemoteAudioStateChanged" + const val LocalPublishFallbackToAudioOnly = "LocalPublishFallbackToAudioOnly" + const val RemoteSubscribeFallbackToAudioOnly = "RemoteSubscribeFallbackToAudioOnly" + const val RtcStats = "RtcStats" + const val NetworkQuality = "NetworkQuality" + const val RemoteVideoStats = "RemoteVideoStats" + const val RemoteAudioStats = "RemoteAudioStats" + const val RtmpStreamingStateChanged = "RtmpStreamingStateChanged" + const val TranscodingUpdated = "TranscodingUpdated" + const val StreamInjectedStatus = "StreamInjectedStatus" + const val StreamMessage = "StreamMessage" + const val StreamMessageError = "StreamMessageError" + const val ChannelMediaRelayStateChanged = "ChannelMediaRelayStateChanged" + const val ChannelMediaRelayEvent = "ChannelMediaRelayEvent" + const val MetadataReceived = "MetadataReceived" + const val AudioPublishStateChanged = "AudioPublishStateChanged" + const val VideoPublishStateChanged = "VideoPublishStateChanged" + const val AudioSubscribeStateChanged = "AudioSubscribeStateChanged" + const val VideoSubscribeStateChanged = "VideoSubscribeStateChanged" + const val RtmpStreamingEvent = "RtmpStreamingEvent" + + fun toMap(): Map { + return hashMapOf( + "Warning" to Warning, + "Error" to Error, + "JoinChannelSuccess" to JoinChannelSuccess, + "RejoinChannelSuccess" to RejoinChannelSuccess, + "LeaveChannel" to LeaveChannel, + "ClientRoleChanged" to ClientRoleChanged, + "UserJoined" to UserJoined, + "UserOffline" to UserOffline, + "ConnectionStateChanged" to ConnectionStateChanged, + "ConnectionLost" to ConnectionLost, + "TokenPrivilegeWillExpire" to TokenPrivilegeWillExpire, + "RequestToken" to RequestToken, + "ActiveSpeaker" to ActiveSpeaker, + "VideoSizeChanged" to VideoSizeChanged, + "RemoteVideoStateChanged" to RemoteVideoStateChanged, + "RemoteAudioStateChanged" to RemoteAudioStateChanged, + "LocalPublishFallbackToAudioOnly" to LocalPublishFallbackToAudioOnly, + "RemoteSubscribeFallbackToAudioOnly" to RemoteSubscribeFallbackToAudioOnly, + "RtcStats" to RtcStats, + "NetworkQuality" to NetworkQuality, + "RemoteVideoStats" to RemoteVideoStats, + "RemoteAudioStats" to RemoteAudioStats, + "RtmpStreamingStateChanged" to RtmpStreamingStateChanged, + "TranscodingUpdated" to TranscodingUpdated, + "StreamInjectedStatus" to StreamInjectedStatus, + "StreamMessage" to StreamMessage, + "StreamMessageError" to StreamMessageError, + "ChannelMediaRelayStateChanged" to ChannelMediaRelayStateChanged, + "ChannelMediaRelayEvent" to ChannelMediaRelayEvent, + "MetadataReceived" to MetadataReceived, + "AudioPublishStateChanged" to AudioPublishStateChanged, + "VideoPublishStateChanged" to VideoPublishStateChanged, + "AudioSubscribeStateChanged" to AudioSubscribeStateChanged, + "VideoSubscribeStateChanged" to VideoSubscribeStateChanged, + "RtmpStreamingEvent" to RtmpStreamingEvent + ) + } + } } class RtcChannelEventHandler( - private val emitter: (methodName: String, data: Map?) -> Unit + private val emitter: (methodName: String, data: Map?) -> Unit ) : IRtcChannelEventHandler() { - companion object { - const val PREFIX = "io.agora.rtc." - } - - private fun callback(methodName: String, channel: RtcChannel?, vararg data: Any?) { - channel?.let { - emitter(methodName, hashMapOf( - "channelId" to it.channelId(), - "data" to data.toList() - )) - } - } - - override fun onChannelWarning(rtcChannel: RtcChannel?, @Annotations.AgoraWarningCode warn: Int) { - callback(RtcChannelEvents.Warning, rtcChannel, warn) - } - - override fun onChannelError(rtcChannel: RtcChannel?, @Annotations.AgoraErrorCode err: Int) { - callback(RtcChannelEvents.Error, rtcChannel, err) - } - - override fun onJoinChannelSuccess(rtcChannel: RtcChannel?, uid: Int, elapsed: Int) { - 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) - } - - override fun onLeaveChannel(rtcChannel: RtcChannel?, stats: IRtcEngineEventHandler.RtcStats?) { - callback(RtcChannelEvents.LeaveChannel, rtcChannel, stats?.toMap()) - } - - override fun onClientRoleChanged(rtcChannel: RtcChannel?, @Annotations.AgoraClientRole oldRole: Int, @Annotations.AgoraClientRole newRole: Int) { - callback(RtcChannelEvents.ClientRoleChanged, rtcChannel, oldRole, newRole) - } - - override fun onUserJoined(rtcChannel: RtcChannel?, uid: Int, elapsed: Int) { - callback(RtcChannelEvents.UserJoined, rtcChannel, uid, elapsed) - } - - override fun onUserOffline(rtcChannel: RtcChannel?, uid: Int, @Annotations.AgoraUserOfflineReason reason: Int) { - callback(RtcChannelEvents.UserOffline, rtcChannel, uid, reason) - } - - override fun onConnectionStateChanged(rtcChannel: RtcChannel?, @Annotations.AgoraConnectionStateType state: Int, @Annotations.AgoraConnectionChangedReason reason: Int) { - callback(RtcChannelEvents.ConnectionStateChanged, rtcChannel, state, reason) - } - - override fun onConnectionLost(rtcChannel: RtcChannel?) { - callback(RtcChannelEvents.ConnectionLost, rtcChannel) - } - - override fun onTokenPrivilegeWillExpire(rtcChannel: RtcChannel?, token: String?) { - callback(RtcChannelEvents.TokenPrivilegeWillExpire, rtcChannel, token) - } - - override fun onRequestToken(rtcChannel: RtcChannel?) { - callback(RtcChannelEvents.RequestToken, rtcChannel) + companion object { + const val PREFIX = "io.agora.rtc." + } + + private fun callback(methodName: String, channel: RtcChannel?, vararg data: Any?) { + channel?.let { + emitter(methodName, hashMapOf( + "channelId" to it.channelId(), + "data" to data.toList() + )) } + } - override fun onActiveSpeaker(rtcChannel: RtcChannel?, uid: Int) { - callback(RtcChannelEvents.ActiveSpeaker, rtcChannel, uid) - } + override fun onChannelWarning(rtcChannel: RtcChannel?, @Annotations.AgoraWarningCode warn: Int) { + callback(RtcChannelEvents.Warning, rtcChannel, warn) + } - override fun onVideoSizeChanged(rtcChannel: RtcChannel?, uid: Int, width: Int, height: Int, @IntRange(from = 0, to = 360) rotation: Int) { - callback(RtcChannelEvents.VideoSizeChanged, rtcChannel, uid, width, height, rotation) - } + override fun onChannelError(rtcChannel: RtcChannel?, @Annotations.AgoraErrorCode err: Int) { + callback(RtcChannelEvents.Error, rtcChannel, err) + } - override fun onRemoteVideoStateChanged(rtcChannel: RtcChannel?, uid: Int, @Annotations.AgoraVideoRemoteState state: Int, @Annotations.AgoraVideoRemoteStateReason reason: Int, elapsed: Int) { - callback(RtcChannelEvents.RemoteVideoStateChanged, rtcChannel, uid, state, reason, elapsed) - } + override fun onJoinChannelSuccess(rtcChannel: RtcChannel?, uid: Int, elapsed: Int) { + callback(RtcChannelEvents.JoinChannelSuccess, rtcChannel, rtcChannel?.channelId(), uid, elapsed) + } - override fun onRemoteAudioStateChanged(rtcChannel: RtcChannel?, uid: Int, @Annotations.AgoraAudioRemoteState state: Int, @Annotations.AgoraAudioRemoteStateReason reason: Int, elapsed: Int) { - callback(RtcChannelEvents.RemoteAudioStateChanged, rtcChannel, uid, state, reason, elapsed) - } + override fun onRejoinChannelSuccess(rtcChannel: RtcChannel?, uid: Int, elapsed: Int) { + callback(RtcChannelEvents.RejoinChannelSuccess, rtcChannel, rtcChannel?.channelId(), uid, elapsed) + } - override fun onLocalPublishFallbackToAudioOnly(rtcChannel: RtcChannel?, isFallbackOrRecover: Boolean) { - callback(RtcChannelEvents.LocalPublishFallbackToAudioOnly, rtcChannel, isFallbackOrRecover) - } + override fun onLeaveChannel(rtcChannel: RtcChannel?, stats: IRtcEngineEventHandler.RtcStats?) { + callback(RtcChannelEvents.LeaveChannel, rtcChannel, stats?.toMap()) + } - override fun onRemoteSubscribeFallbackToAudioOnly(rtcChannel: RtcChannel?, uid: Int, isFallbackOrRecover: Boolean) { - callback(RtcChannelEvents.RemoteSubscribeFallbackToAudioOnly, rtcChannel, uid, isFallbackOrRecover) - } - - override fun onRtcStats(rtcChannel: RtcChannel?, stats: IRtcEngineEventHandler.RtcStats?) { - callback(RtcChannelEvents.RtcStats, rtcChannel, stats?.toMap()) - } - - override fun onNetworkQuality(rtcChannel: RtcChannel?, uid: Int, @Annotations.AgoraNetworkQuality txQuality: Int, @Annotations.AgoraNetworkQuality rxQuality: Int) { - callback(RtcChannelEvents.NetworkQuality, rtcChannel, uid, txQuality, rxQuality) - } - - override fun onRemoteVideoStats(rtcChannel: RtcChannel?, stats: IRtcEngineEventHandler.RemoteVideoStats?) { - callback(RtcChannelEvents.RemoteVideoStats, rtcChannel, stats?.toMap()) - } + override fun onClientRoleChanged(rtcChannel: RtcChannel?, @Annotations.AgoraClientRole oldRole: Int, @Annotations.AgoraClientRole newRole: Int) { + callback(RtcChannelEvents.ClientRoleChanged, rtcChannel, oldRole, newRole) + } - override fun onRemoteAudioStats(rtcChannel: RtcChannel?, stats: IRtcEngineEventHandler.RemoteAudioStats?) { - callback(RtcChannelEvents.RemoteAudioStats, rtcChannel, stats?.toMap()) - } + override fun onUserJoined(rtcChannel: RtcChannel?, uid: Int, elapsed: Int) { + callback(RtcChannelEvents.UserJoined, rtcChannel, uid, elapsed) + } - override fun onRtmpStreamingStateChanged(rtcChannel: RtcChannel?, url: String?, @Annotations.AgoraRtmpStreamingState state: Int, @Annotations.AgoraRtmpStreamingErrorCode errCode: Int) { - callback(RtcChannelEvents.RtmpStreamingStateChanged, rtcChannel, url, state, errCode) - } + override fun onUserOffline(rtcChannel: RtcChannel?, uid: Int, @Annotations.AgoraUserOfflineReason reason: Int) { + callback(RtcChannelEvents.UserOffline, rtcChannel, uid, reason) + } - override fun onTranscodingUpdated(rtcChannel: RtcChannel?) { - callback(RtcChannelEvents.TranscodingUpdated, rtcChannel) - } + override fun onConnectionStateChanged(rtcChannel: RtcChannel?, @Annotations.AgoraConnectionStateType state: Int, @Annotations.AgoraConnectionChangedReason reason: Int) { + callback(RtcChannelEvents.ConnectionStateChanged, rtcChannel, state, reason) + } + + override fun onConnectionLost(rtcChannel: RtcChannel?) { + callback(RtcChannelEvents.ConnectionLost, rtcChannel) + } + + override fun onTokenPrivilegeWillExpire(rtcChannel: RtcChannel?, token: String?) { + callback(RtcChannelEvents.TokenPrivilegeWillExpire, rtcChannel, token) + } + + override fun onRequestToken(rtcChannel: RtcChannel?) { + callback(RtcChannelEvents.RequestToken, rtcChannel) + } + + override fun onActiveSpeaker(rtcChannel: RtcChannel?, uid: Int) { + callback(RtcChannelEvents.ActiveSpeaker, rtcChannel, uid) + } + + override fun onVideoSizeChanged(rtcChannel: RtcChannel?, uid: Int, width: Int, height: Int, @IntRange(from = 0, to = 360) rotation: Int) { + callback(RtcChannelEvents.VideoSizeChanged, rtcChannel, uid, width, height, rotation) + } + + override fun onRemoteVideoStateChanged(rtcChannel: RtcChannel?, uid: Int, @Annotations.AgoraVideoRemoteState state: Int, @Annotations.AgoraVideoRemoteStateReason reason: Int, elapsed: Int) { + callback(RtcChannelEvents.RemoteVideoStateChanged, rtcChannel, uid, state, reason, elapsed) + } + + override fun onRemoteAudioStateChanged(rtcChannel: RtcChannel?, uid: Int, @Annotations.AgoraAudioRemoteState state: Int, @Annotations.AgoraAudioRemoteStateReason reason: Int, elapsed: Int) { + callback(RtcChannelEvents.RemoteAudioStateChanged, rtcChannel, uid, state, reason, elapsed) + } + + override fun onLocalPublishFallbackToAudioOnly(rtcChannel: RtcChannel?, isFallbackOrRecover: Boolean) { + callback(RtcChannelEvents.LocalPublishFallbackToAudioOnly, rtcChannel, isFallbackOrRecover) + } + + override fun onRemoteSubscribeFallbackToAudioOnly(rtcChannel: RtcChannel?, uid: Int, isFallbackOrRecover: Boolean) { + callback(RtcChannelEvents.RemoteSubscribeFallbackToAudioOnly, rtcChannel, uid, isFallbackOrRecover) + } + + override fun onRtcStats(rtcChannel: RtcChannel?, stats: IRtcEngineEventHandler.RtcStats?) { + callback(RtcChannelEvents.RtcStats, rtcChannel, stats?.toMap()) + } + + override fun onNetworkQuality(rtcChannel: RtcChannel?, uid: Int, @Annotations.AgoraNetworkQuality txQuality: Int, @Annotations.AgoraNetworkQuality rxQuality: Int) { + callback(RtcChannelEvents.NetworkQuality, rtcChannel, uid, txQuality, rxQuality) + } + + override fun onRemoteVideoStats(rtcChannel: RtcChannel?, stats: IRtcEngineEventHandler.RemoteVideoStats?) { + callback(RtcChannelEvents.RemoteVideoStats, rtcChannel, stats?.toMap()) + } + + override fun onRemoteAudioStats(rtcChannel: RtcChannel?, stats: IRtcEngineEventHandler.RemoteAudioStats?) { + callback(RtcChannelEvents.RemoteAudioStats, rtcChannel, stats?.toMap()) + } + + override fun onRtmpStreamingStateChanged(rtcChannel: RtcChannel?, url: String?, @Annotations.AgoraRtmpStreamingState state: Int, @Annotations.AgoraRtmpStreamingErrorCode errCode: Int) { + callback(RtcChannelEvents.RtmpStreamingStateChanged, rtcChannel, url, state, errCode) + } + + override fun onTranscodingUpdated(rtcChannel: RtcChannel?) { + callback(RtcChannelEvents.TranscodingUpdated, rtcChannel) + } - override fun onStreamInjectedStatus(rtcChannel: RtcChannel?, url: String?, uid: Int, @Annotations.AgoraInjectStreamStatus status: Int) { - callback(RtcChannelEvents.StreamInjectedStatus, rtcChannel, url, uid, status) - } + override fun onStreamInjectedStatus(rtcChannel: RtcChannel?, url: String?, uid: Int, @Annotations.AgoraInjectStreamStatus status: Int) { + callback(RtcChannelEvents.StreamInjectedStatus, rtcChannel, url, uid, status) + } - override fun onStreamMessage(rtcChannel: RtcChannel?, uid: Int, streamId: Int, data: ByteArray?) { - callback(RtcChannelEvents.StreamMessage, rtcChannel, uid, streamId, data?.let { String(it, Charsets.UTF_8) }) - } + override fun onStreamMessage(rtcChannel: RtcChannel?, uid: Int, streamId: Int, data: ByteArray?) { + callback(RtcChannelEvents.StreamMessage, rtcChannel, uid, streamId, data?.let { String(it, Charsets.UTF_8) }) + } - override fun onStreamMessageError(rtcChannel: RtcChannel?, uid: Int, streamId: Int, @Annotations.AgoraErrorCode error: Int, missed: Int, cached: Int) { - callback(RtcChannelEvents.StreamMessageError, rtcChannel, uid, streamId, error, missed, cached) - } + override fun onStreamMessageError(rtcChannel: RtcChannel?, uid: Int, streamId: Int, @Annotations.AgoraErrorCode error: Int, missed: Int, cached: Int) { + callback(RtcChannelEvents.StreamMessageError, rtcChannel, uid, streamId, error, missed, cached) + } - override fun onChannelMediaRelayStateChanged(rtcChannel: RtcChannel?, @Annotations.AgoraChannelMediaRelayState state: Int, @Annotations.AgoraChannelMediaRelayError code: Int) { - callback(RtcChannelEvents.ChannelMediaRelayStateChanged, rtcChannel, state, code) - } + override fun onChannelMediaRelayStateChanged(rtcChannel: RtcChannel?, @Annotations.AgoraChannelMediaRelayState state: Int, @Annotations.AgoraChannelMediaRelayError code: Int) { + callback(RtcChannelEvents.ChannelMediaRelayStateChanged, rtcChannel, state, code) + } - override fun onChannelMediaRelayEvent(rtcChannel: RtcChannel?, @Annotations.AgoraChannelMediaRelayEvent code: Int) { - callback(RtcChannelEvents.ChannelMediaRelayEvent, rtcChannel, code) - } + override fun onChannelMediaRelayEvent(rtcChannel: RtcChannel?, @Annotations.AgoraChannelMediaRelayEvent code: Int) { + callback(RtcChannelEvents.ChannelMediaRelayEvent, rtcChannel, code) + } - override fun onAudioPublishStateChanged(rtcChannel: RtcChannel?, @Annotations.AgoraStreamPublishState oldState: Int, @Annotations.AgoraStreamPublishState newState: Int, elapseSinceLastState: Int) { - callback(RtcChannelEvents.AudioPublishStateChanged, rtcChannel, rtcChannel?.channelId(), oldState, newState, elapseSinceLastState) - } + override fun onAudioPublishStateChanged(rtcChannel: RtcChannel?, @Annotations.AgoraStreamPublishState oldState: Int, @Annotations.AgoraStreamPublishState newState: Int, elapseSinceLastState: Int) { + 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) - } + override fun onVideoPublishStateChanged(rtcChannel: RtcChannel?, @Annotations.AgoraStreamPublishState oldState: Int, @Annotations.AgoraStreamPublishState newState: Int, elapseSinceLastState: Int) { + 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) - } + 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) + } - 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) - } + 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) + } - override fun onRtmpStreamingEvent(rtcChannel: RtcChannel?, url: String?, @Annotations.AgoraRtmpStreamingEvent errCode: Int) { - callback(RtcChannelEvents.RtmpStreamingEvent, rtcChannel, url, errCode) - } + override fun onRtmpStreamingEvent(rtcChannel: RtcChannel?, url: String?, @Annotations.AgoraRtmpStreamingEvent errCode: Int) { + callback(RtcChannelEvents.RtmpStreamingEvent, rtcChannel, url, errCode) + } } diff --git a/RtcEngine.kt b/RtcEngine.kt index 38a3561f3..9249a05f3 100644 --- a/RtcEngine.kt +++ b/RtcEngine.kt @@ -6,901 +6,923 @@ import io.agora.rtc.internal.EncryptionConfig import io.agora.rtc.models.UserInfo class IRtcEngine { - interface RtcEngineInterface : RtcUserInfoInterface, RtcAudioInterface, RtcVideoInterface, - RtcAudioMixingInterface, RtcAudioEffectInterface, RtcVoiceChangerInterface, - RtcVoicePositionInterface, RtcPublishStreamInterface, RtcMediaRelayInterface, - RtcAudioRouteInterface, RtcEarMonitoringInterface, RtcDualStreamInterface, - RtcFallbackInterface, RtcTestInterface, RtcMediaMetadataInterface, - RtcWatermarkInterface, RtcEncryptionInterface, RtcAudioRecorderInterface, - RtcInjectStreamInterface, RtcCameraInterface, RtcStreamMessageInterface { - fun create(params: Map, callback: Callback) + interface RtcEngineInterface : RtcUserInfoInterface, RtcAudioInterface, RtcVideoInterface, + RtcAudioMixingInterface, RtcAudioEffectInterface, RtcVoiceChangerInterface, + RtcVoicePositionInterface, RtcPublishStreamInterface, RtcMediaRelayInterface, + RtcAudioRouteInterface, RtcEarMonitoringInterface, RtcDualStreamInterface, + RtcFallbackInterface, RtcTestInterface, RtcMediaMetadataInterface, + RtcWatermarkInterface, RtcEncryptionInterface, RtcAudioRecorderInterface, + RtcInjectStreamInterface, RtcCameraInterface, RtcStreamMessageInterface { + fun create(params: Map, callback: Callback) - fun destroy(callback: Callback) + fun destroy(callback: Callback) - fun setChannelProfile(params: Map, callback: Callback) + fun setChannelProfile(params: Map, callback: Callback) - fun setClientRole(params: Map, callback: Callback) + fun setClientRole(params: Map, callback: Callback) - fun joinChannel(params: Map, callback: Callback) + fun joinChannel(params: Map, callback: Callback) - fun switchChannel(params: Map, callback: Callback) + fun switchChannel(params: Map, callback: Callback) - fun leaveChannel(callback: Callback) + fun leaveChannel(callback: Callback) - fun renewToken(params: Map, callback: Callback) + fun renewToken(params: Map, callback: Callback) - @Deprecated("") - fun enableWebSdkInteroperability(params: Map, callback: Callback) + @Deprecated("") + fun enableWebSdkInteroperability(params: Map, callback: Callback) - fun getConnectionState(callback: Callback) + fun getConnectionState(callback: Callback) - fun sendCustomReportMessage(params: Map, callback: Callback) + fun sendCustomReportMessage(params: Map, callback: Callback) - fun getCallId(callback: Callback) + fun getCallId(callback: Callback) - fun rate(params: Map, callback: Callback) + fun rate(params: Map, callback: Callback) - fun complain(params: Map, callback: Callback) + fun complain(params: Map, callback: Callback) - fun setLogFile(params: Map, callback: Callback) + fun setLogFile(params: Map, callback: Callback) - fun setLogFilter(params: Map, callback: Callback) + fun setLogFilter(params: Map, callback: Callback) - fun setLogFileSize(params: Map, callback: Callback) + fun setLogFileSize(params: Map, callback: Callback) - fun setParameters(params: Map, callback: Callback) + fun setParameters(params: Map, callback: Callback) - fun getNativeHandle(callback: Callback) - } - - interface RtcUserInfoInterface { - fun registerLocalUserAccount(params: Map, callback: Callback) - - fun joinChannelWithUserAccount(params: Map, callback: Callback) - - fun getUserInfoByUserAccount(params: Map, callback: Callback) - - fun getUserInfoByUid(params: Map, callback: Callback) - } - - interface RtcAudioInterface { - fun enableAudio(callback: Callback) - - fun disableAudio(callback: Callback) - - fun setAudioProfile(params: Map, callback: Callback) - - fun adjustRecordingSignalVolume(params: Map, callback: Callback) - - fun adjustUserPlaybackSignalVolume(params: Map, callback: Callback) - - fun adjustPlaybackSignalVolume(params: Map, callback: Callback) - - fun enableLocalAudio(params: Map, callback: Callback) - - fun muteLocalAudioStream(params: Map, callback: Callback) - - fun muteRemoteAudioStream(params: Map, callback: Callback) - - fun muteAllRemoteAudioStreams(params: Map, callback: Callback) - - fun setDefaultMuteAllRemoteAudioStreams(params: Map, callback: Callback) - - fun enableAudioVolumeIndication(params: Map, callback: Callback) - } - - interface RtcVideoInterface { - fun enableVideo(callback: Callback) - - fun disableVideo(callback: Callback) - - fun setVideoEncoderConfiguration(params: Map, callback: Callback) - - fun startPreview(callback: Callback) - - fun stopPreview(callback: Callback) - - fun enableLocalVideo(params: Map, callback: Callback) - - fun muteLocalVideoStream(params: Map, callback: Callback) - - fun muteRemoteVideoStream(params: Map, callback: Callback) - - fun muteAllRemoteVideoStreams(params: Map, callback: Callback) + fun getNativeHandle(callback: Callback) + } - fun setDefaultMuteAllRemoteVideoStreams(params: Map, callback: Callback) + interface RtcUserInfoInterface { + fun registerLocalUserAccount(params: Map, callback: Callback) - fun setBeautyEffectOptions(params: Map, callback: Callback) - } - - interface RtcAudioMixingInterface { - fun startAudioMixing(params: Map, callback: Callback) - - fun stopAudioMixing(callback: Callback) - - fun pauseAudioMixing(callback: Callback) - - fun resumeAudioMixing(callback: Callback) - - fun adjustAudioMixingVolume(params: Map, callback: Callback) - - fun adjustAudioMixingPlayoutVolume(params: Map, callback: Callback) + fun joinChannelWithUserAccount(params: Map, callback: Callback) - fun adjustAudioMixingPublishVolume(params: Map, callback: Callback) + fun getUserInfoByUserAccount(params: Map, callback: Callback) - fun getAudioMixingPlayoutVolume(callback: Callback) + fun getUserInfoByUid(params: Map, callback: Callback) + } - fun getAudioMixingPublishVolume(callback: Callback) + interface RtcAudioInterface { + fun enableAudio(callback: Callback) - fun getAudioMixingDuration(callback: Callback) + fun disableAudio(callback: Callback) - fun getAudioMixingCurrentPosition(callback: Callback) + fun setAudioProfile(params: Map, callback: Callback) - fun setAudioMixingPosition(params: Map, callback: Callback) + fun adjustRecordingSignalVolume(params: Map, callback: Callback) - fun setAudioMixingPitch(params: Map, callback: Callback) - } - - interface RtcAudioEffectInterface { - fun getEffectsVolume(callback: Callback) - - fun setEffectsVolume(params: Map, callback: Callback) - - fun setVolumeOfEffect(params: Map, callback: Callback) + fun adjustUserPlaybackSignalVolume(params: Map, callback: Callback) - fun playEffect(params: Map, callback: Callback) + fun adjustPlaybackSignalVolume(params: Map, callback: Callback) - fun stopEffect(params: Map, callback: Callback) + fun enableLocalAudio(params: Map, callback: Callback) - fun stopAllEffects(callback: Callback) + fun muteLocalAudioStream(params: Map, callback: Callback) - fun preloadEffect(params: Map, callback: Callback) + fun muteRemoteAudioStream(params: Map, callback: Callback) - fun unloadEffect(params: Map, callback: Callback) + fun muteAllRemoteAudioStreams(params: Map, callback: Callback) - fun pauseEffect(params: Map, callback: Callback) + fun setDefaultMuteAllRemoteAudioStreams(params: Map, callback: Callback) - fun pauseAllEffects(callback: Callback) + fun enableAudioVolumeIndication(params: Map, callback: Callback) + } - fun resumeEffect(params: Map, callback: Callback) - - fun resumeAllEffects(callback: Callback) - - fun setAudioSessionOperationRestriction(params: Map, callback: Callback) - } + interface RtcVideoInterface { + fun enableVideo(callback: Callback) - interface RtcVoiceChangerInterface { - fun setLocalVoiceChanger(params: Map, callback: Callback) + fun disableVideo(callback: Callback) - fun setLocalVoiceReverbPreset(params: Map, callback: Callback) + fun setVideoEncoderConfiguration(params: Map, callback: Callback) - fun setLocalVoicePitch(params: Map, callback: Callback) + fun startPreview(callback: Callback) - fun setLocalVoiceEqualization(params: Map, callback: Callback) + fun stopPreview(callback: Callback) - fun setLocalVoiceReverb(params: Map, callback: Callback) - } + fun enableLocalVideo(params: Map, callback: Callback) - interface RtcVoicePositionInterface { - fun enableSoundPositionIndication(params: Map, callback: Callback) + fun muteLocalVideoStream(params: Map, callback: Callback) - fun setRemoteVoicePosition(params: Map, callback: Callback) - } + fun muteRemoteVideoStream(params: Map, callback: Callback) - interface RtcPublishStreamInterface { - fun setLiveTranscoding(params: Map, callback: Callback) + fun muteAllRemoteVideoStreams(params: Map, callback: Callback) - fun addPublishStreamUrl(params: Map, callback: Callback) + fun setDefaultMuteAllRemoteVideoStreams(params: Map, callback: Callback) - fun removePublishStreamUrl(params: Map, callback: Callback) - } + fun setBeautyEffectOptions(params: Map, callback: Callback) + } - interface RtcMediaRelayInterface { - fun startChannelMediaRelay(params: Map, callback: Callback) + interface RtcAudioMixingInterface { + fun startAudioMixing(params: Map, callback: Callback) - fun updateChannelMediaRelay(params: Map, callback: Callback) + fun stopAudioMixing(callback: Callback) - fun stopChannelMediaRelay(callback: Callback) - } + fun pauseAudioMixing(callback: Callback) - interface RtcAudioRouteInterface { - fun setDefaultAudioRoutetoSpeakerphone(params: Map, callback: Callback) + fun resumeAudioMixing(callback: Callback) - fun setEnableSpeakerphone(params: Map, callback: Callback) + fun adjustAudioMixingVolume(params: Map, callback: Callback) - fun isSpeakerphoneEnabled(callback: Callback) - } + fun adjustAudioMixingPlayoutVolume(params: Map, callback: Callback) - interface RtcEarMonitoringInterface { - fun enableInEarMonitoring(params: Map, callback: Callback) + fun adjustAudioMixingPublishVolume(params: Map, callback: Callback) - fun setInEarMonitoringVolume(params: Map, callback: Callback) - } + fun getAudioMixingPlayoutVolume(callback: Callback) - interface RtcDualStreamInterface { - fun enableDualStreamMode(params: Map, callback: Callback) + fun getAudioMixingPublishVolume(callback: Callback) - fun setRemoteVideoStreamType(params: Map, callback: Callback) + fun getAudioMixingDuration(callback: Callback) - fun setRemoteDefaultVideoStreamType(params: Map, callback: Callback) - } + fun getAudioMixingCurrentPosition(callback: Callback) - interface RtcFallbackInterface { - fun setLocalPublishFallbackOption(params: Map, callback: Callback) + fun setAudioMixingPosition(params: Map, callback: Callback) - fun setRemoteSubscribeFallbackOption(params: Map, callback: Callback) + fun setAudioMixingPitch(params: Map, callback: Callback) + } - fun setRemoteUserPriority(params: Map, callback: Callback) - } + interface RtcAudioEffectInterface { + fun getEffectsVolume(callback: Callback) - interface RtcTestInterface { - fun startEchoTest(params: Map, callback: Callback) + fun setEffectsVolume(params: Map, callback: Callback) - fun stopEchoTest(callback: Callback) + fun setVolumeOfEffect(params: Map, callback: Callback) - fun enableLastmileTest(callback: Callback) + fun playEffect(params: Map, callback: Callback) - fun disableLastmileTest(callback: Callback) + fun stopEffect(params: Map, callback: Callback) - fun startLastmileProbeTest(params: Map, callback: Callback) + fun stopAllEffects(callback: Callback) - fun stopLastmileProbeTest(callback: Callback) - } + fun preloadEffect(params: Map, callback: Callback) - interface RtcMediaMetadataInterface { - fun registerMediaMetadataObserver(callback: Callback) + fun unloadEffect(params: Map, callback: Callback) - fun unregisterMediaMetadataObserver(callback: Callback) + fun pauseEffect(params: Map, callback: Callback) - fun setMaxMetadataSize(params: Map, callback: Callback) + fun pauseAllEffects(callback: Callback) - fun sendMetadata(params: Map, callback: Callback) - } + fun resumeEffect(params: Map, callback: Callback) - interface RtcWatermarkInterface { - fun addVideoWatermark(params: Map, callback: Callback) + fun resumeAllEffects(callback: Callback) - fun clearVideoWatermarks(callback: Callback) - } + fun setAudioSessionOperationRestriction(params: Map, callback: Callback) + } - interface RtcEncryptionInterface { - fun setEncryptionSecret(params: Map, callback: Callback) + interface RtcVoiceChangerInterface { + @Deprecated("") + fun setLocalVoiceChanger(params: Map, callback: Callback) - fun setEncryptionMode(params: Map, callback: Callback) + @Deprecated("") + fun setLocalVoiceReverbPreset(params: Map, callback: Callback) - fun enableEncryption(params: Map, callback: Callback) - } + fun setLocalVoicePitch(params: Map, callback: Callback) - interface RtcAudioRecorderInterface { - fun startAudioRecording(params: Map, callback: Callback) + fun setLocalVoiceEqualization(params: Map, callback: Callback) - fun stopAudioRecording(callback: Callback) - } + fun setLocalVoiceReverb(params: Map, callback: Callback) - interface RtcInjectStreamInterface { - fun addInjectStreamUrl(params: Map, callback: Callback) + fun setAudioEffectPreset(params: Map, callback: Callback) - fun removeInjectStreamUrl(params: Map, callback: Callback) - } + fun setVoiceBeautifierPreset(params: Map, callback: Callback) - interface RtcCameraInterface { - fun switchCamera(callback: Callback) + fun setAudioEffectParameters(params: Map, callback: Callback) + } - fun isCameraZoomSupported(callback: Callback) + interface RtcVoicePositionInterface { + fun enableSoundPositionIndication(params: Map, callback: Callback) - fun isCameraTorchSupported(callback: Callback) + fun setRemoteVoicePosition(params: Map, callback: Callback) + } - fun isCameraFocusSupported(callback: Callback) + interface RtcPublishStreamInterface { + fun setLiveTranscoding(params: Map, callback: Callback) - fun isCameraExposurePositionSupported(callback: Callback) + fun addPublishStreamUrl(params: Map, callback: Callback) - fun isCameraAutoFocusFaceModeSupported(callback: Callback) + fun removePublishStreamUrl(params: Map, callback: Callback) + } - fun setCameraZoomFactor(params: Map, callback: Callback) + interface RtcMediaRelayInterface { + fun startChannelMediaRelay(params: Map, callback: Callback) - fun getCameraMaxZoomFactor(callback: Callback) + fun updateChannelMediaRelay(params: Map, callback: Callback) - fun setCameraFocusPositionInPreview(params: Map, callback: Callback) + fun stopChannelMediaRelay(callback: Callback) + } - fun setCameraExposurePosition(params: Map, callback: Callback) + interface RtcAudioRouteInterface { + fun setDefaultAudioRoutetoSpeakerphone(params: Map, callback: Callback) - fun enableFaceDetection(params: Map, callback: Callback) + fun setEnableSpeakerphone(params: Map, callback: Callback) - fun setCameraTorchOn(params: Map, callback: Callback) + fun isSpeakerphoneEnabled(callback: Callback) + } - fun setCameraAutoFocusFaceModeEnabled(params: Map, callback: Callback) + interface RtcEarMonitoringInterface { + fun enableInEarMonitoring(params: Map, callback: Callback) - fun setCameraCapturerConfiguration(params: Map, callback: Callback) - } - - interface RtcStreamMessageInterface { - fun createDataStream(params: Map, callback: Callback) - - fun sendStreamMessage(params: Map, callback: Callback) - } -} - -class RtcEngineManager( - private val emit: (methodName: String, data: Map?) -> Unit -) : IRtcEngine.RtcEngineInterface { - var engine: RtcEngine? = null - private set - private var mediaObserver: MediaObserver? = null - - fun release() { - RtcEngine.destroy() - engine = null - mediaObserver = null - } - - override fun create(params: Map, callback: Callback) { - engine = RtcEngineEx.create(RtcEngineConfig().apply { - mContext = params["context"] as Context - mAppId = params["appId"] as String - mAreaCode = (params["areaCode"] as Number).toInt() - mEventHandler = RtcEngineEventHandler { methodName, data -> - emit(methodName, data) - } - }) - callback.code((engine as RtcEngineEx).setAppType((params["appType"] as Number).toInt())) - } - - override fun destroy(callback: Callback) { - callback.resolve(engine) { release() } - } - - override fun setChannelProfile(params: Map, callback: Callback) { - callback.code(engine?.setChannelProfile((params["profile"] as Number).toInt())) - } - - override fun setClientRole(params: Map, callback: Callback) { - callback.code(engine?.setClientRole((params["role"] as Number).toInt())) - } - - override fun joinChannel(params: Map, callback: Callback) { - callback.code(engine?.joinChannel(params["token"] as? String, params["channelName"] as String, params["optionalInfo"] as? String, (params["optionalUid"] as Number).toInt())) - } - - override fun switchChannel(params: Map, callback: Callback) { - callback.code(engine?.switchChannel(params["token"] as? String, params["channelName"] as String)) - } - - override fun leaveChannel(callback: Callback) { - callback.code(engine?.leaveChannel()) - } - - override fun renewToken(params: Map, callback: Callback) { - callback.code(engine?.renewToken(params["token"] as String)) - } - - override fun enableWebSdkInteroperability(params: Map, callback: Callback) { - callback.code(engine?.enableWebSdkInteroperability(params["enabled"] as Boolean)) - } - - override fun getConnectionState(callback: Callback) { - callback.resolve(engine) { it.connectionState } - } - - override fun sendCustomReportMessage(params: Map, callback: Callback) { - callback.code(engine?.sendCustomReportMessage(params["id"] as String, params["category"] as String, params["event"] as String, params["label"] as String, (params["value"] as Number).toInt())) - } - - override fun getCallId(callback: Callback) { - callback.resolve(engine) { it.callId } - } - - override fun rate(params: Map, callback: Callback) { - callback.code(engine?.rate(params["callId"] as String, (params["rating"] as Number).toInt(), params["description"] as? String)) - } - - override fun complain(params: Map, callback: Callback) { - callback.code(engine?.complain(params["callId"] as String, params["description"] as String)) - } - - override fun setLogFile(params: Map, callback: Callback) { - callback.code(engine?.setLogFile(params["filePath"] as String)) - } - - override fun setLogFilter(params: Map, callback: Callback) { - callback.code(engine?.setLogFilter((params["filter"] as Number).toInt())) - } - - override fun setLogFileSize(params: Map, callback: Callback) { - callback.code(engine?.setLogFileSize((params["fileSizeInKBytes"] as Number).toInt())) - } - - override fun setParameters(params: Map, callback: Callback) { - callback.code(engine?.setParameters(params["parameters"] as String)) - } - - override fun getNativeHandle(callback: Callback) { - callback.resolve(engine) { it.nativeHandle } - } - - override fun registerLocalUserAccount(params: Map, callback: Callback) { - callback.code(engine?.registerLocalUserAccount(params["appId"] as String, params["userAccount"] as String)) - } - - override fun joinChannelWithUserAccount(params: Map, callback: Callback) { - callback.code(engine?.joinChannelWithUserAccount(params["token"] as? String, params["channelName"] as String, params["userAccount"] as String)) - } - - override fun getUserInfoByUserAccount(params: Map, callback: Callback) { - callback.resolve(engine) { - val userInfo = UserInfo() - it.getUserInfoByUserAccount(params["userAccount"] as String, userInfo) - userInfo.toMap() - } - } - - override fun getUserInfoByUid(params: Map, callback: Callback) { - callback.resolve(engine) { - val userInfo = UserInfo() - it.getUserInfoByUid((params["uid"] as Number).toInt(), userInfo) - userInfo.toMap() - } - } + fun setInEarMonitoringVolume(params: Map, callback: Callback) + } - override fun enableAudio(callback: Callback) { - callback.code(engine?.enableAudio()) - } + interface RtcDualStreamInterface { + fun enableDualStreamMode(params: Map, callback: Callback) - override fun disableAudio(callback: Callback) { - callback.code(engine?.disableAudio()) - } + fun setRemoteVideoStreamType(params: Map, callback: Callback) - override fun setAudioProfile(params: Map, callback: Callback) { - callback.code(engine?.setAudioProfile((params["profile"] as Number).toInt(), (params["scenario"] as Number).toInt())) - } + fun setRemoteDefaultVideoStreamType(params: Map, callback: Callback) + } - override fun adjustRecordingSignalVolume(params: Map, callback: Callback) { - callback.code(engine?.adjustRecordingSignalVolume((params["volume"] as Number).toInt())) - } + interface RtcFallbackInterface { + fun setLocalPublishFallbackOption(params: Map, callback: Callback) - override fun adjustUserPlaybackSignalVolume(params: Map, callback: Callback) { - callback.code(engine?.adjustUserPlaybackSignalVolume((params["uid"] as Number).toInt(), (params["volume"] as Number).toInt())) - } + fun setRemoteSubscribeFallbackOption(params: Map, callback: Callback) - override fun adjustPlaybackSignalVolume(params: Map, callback: Callback) { - callback.code(engine?.adjustPlaybackSignalVolume((params["volume"] as Number).toInt())) - } + fun setRemoteUserPriority(params: Map, callback: Callback) + } - override fun enableLocalAudio(params: Map, callback: Callback) { - callback.code(engine?.enableLocalAudio(params["enabled"] as Boolean)) - } + interface RtcTestInterface { + fun startEchoTest(params: Map, callback: Callback) - override fun muteLocalAudioStream(params: Map, callback: Callback) { - callback.code(engine?.muteLocalAudioStream(params["muted"] as Boolean)) - } + fun stopEchoTest(callback: Callback) - override fun muteRemoteAudioStream(params: Map, callback: Callback) { - callback.code(engine?.muteRemoteAudioStream((params["uid"] as Number).toInt(), params["muted"] as Boolean)) - } + fun enableLastmileTest(callback: Callback) - override fun muteAllRemoteAudioStreams(params: Map, callback: Callback) { - callback.code(engine?.muteAllRemoteAudioStreams(params["muted"] as Boolean)) - } + fun disableLastmileTest(callback: Callback) - override fun setDefaultMuteAllRemoteAudioStreams(params: Map, callback: Callback) { - callback.code(engine?.setDefaultMuteAllRemoteAudioStreams(params["muted"] as Boolean)) - } + fun startLastmileProbeTest(params: Map, callback: Callback) - override fun enableAudioVolumeIndication(params: Map, callback: Callback) { - callback.code(engine?.enableAudioVolumeIndication((params["interval"] as Number).toInt(), (params["smooth"] as Number).toInt(), params["report_vad"] as Boolean)) - } + fun stopLastmileProbeTest(callback: Callback) + } - override fun enableVideo(callback: Callback) { - callback.code(engine?.enableVideo()) - } + interface RtcMediaMetadataInterface { + fun registerMediaMetadataObserver(callback: Callback) - override fun disableVideo(callback: Callback) { - callback.code(engine?.disableVideo()) - } + fun unregisterMediaMetadataObserver(callback: Callback) - override fun setVideoEncoderConfiguration(params: Map, callback: Callback) { - callback.code(engine?.setVideoEncoderConfiguration(mapToVideoEncoderConfiguration(params["config"] as Map<*, *>))) - } + fun setMaxMetadataSize(params: Map, callback: Callback) - override fun startPreview(callback: Callback) { - callback.code(engine?.startPreview()) - } + fun sendMetadata(params: Map, callback: Callback) + } - override fun stopPreview(callback: Callback) { - callback.code(engine?.stopPreview()) - } + interface RtcWatermarkInterface { + fun addVideoWatermark(params: Map, callback: Callback) - override fun enableLocalVideo(params: Map, callback: Callback) { - callback.code(engine?.enableLocalVideo(params["enabled"] as Boolean)) - } + fun clearVideoWatermarks(callback: Callback) + } - override fun muteLocalVideoStream(params: Map, callback: Callback) { - callback.code(engine?.muteLocalVideoStream(params["muted"] as Boolean)) - } + interface RtcEncryptionInterface { + @Deprecated("") + fun setEncryptionSecret(params: Map, callback: Callback) - override fun muteRemoteVideoStream(params: Map, callback: Callback) { - callback.code(engine?.muteRemoteVideoStream((params["uid"] as Number).toInt(), params["muted"] as Boolean)) - } + @Deprecated("") + fun setEncryptionMode(params: Map, callback: Callback) - override fun muteAllRemoteVideoStreams(params: Map, callback: Callback) { - callback.code(engine?.muteAllRemoteVideoStreams(params["muted"] as Boolean)) - } + fun enableEncryption(params: Map, callback: Callback) + } - override fun setDefaultMuteAllRemoteVideoStreams(params: Map, callback: Callback) { - callback.code(engine?.setDefaultMuteAllRemoteVideoStreams(params["muted"] as Boolean)) - } + interface RtcAudioRecorderInterface { + fun startAudioRecording(params: Map, callback: Callback) - override fun setBeautyEffectOptions(params: Map, callback: Callback) { - callback.code(engine?.setBeautyEffectOptions(params["enabled"] as Boolean, mapToBeautyOptions(params["options"] as Map<*, *>))) - } + fun stopAudioRecording(callback: Callback) + } - override fun startAudioMixing(params: Map, callback: Callback) { - callback.code(engine?.startAudioMixing(params["filePath"] as String, params["loopback"] as Boolean, params["replace"] as Boolean, (params["cycle"] as Number).toInt())) - } + interface RtcInjectStreamInterface { + fun addInjectStreamUrl(params: Map, callback: Callback) - override fun stopAudioMixing(callback: Callback) { - callback.code(engine?.stopAudioMixing()) - } + fun removeInjectStreamUrl(params: Map, callback: Callback) + } - override fun pauseAudioMixing(callback: Callback) { - callback.code(engine?.pauseAudioMixing()) - } + interface RtcCameraInterface { + fun switchCamera(callback: Callback) - override fun resumeAudioMixing(callback: Callback) { - callback.code(engine?.resumeAudioMixing()) - } + fun isCameraZoomSupported(callback: Callback) - override fun adjustAudioMixingVolume(params: Map, callback: Callback) { - callback.code(engine?.adjustAudioMixingVolume((params["volume"] as Number).toInt())) - } + fun isCameraTorchSupported(callback: Callback) - override fun adjustAudioMixingPlayoutVolume(params: Map, callback: Callback) { - callback.code(engine?.adjustAudioMixingPlayoutVolume((params["volume"] as Number).toInt())) - } + fun isCameraFocusSupported(callback: Callback) - override fun adjustAudioMixingPublishVolume(params: Map, callback: Callback) { - callback.code(engine?.adjustAudioMixingPublishVolume((params["volume"] as Number).toInt())) - } + fun isCameraExposurePositionSupported(callback: Callback) - override fun getAudioMixingPlayoutVolume(callback: Callback) { - callback.code(engine?.audioMixingPlayoutVolume) { it } - } + fun isCameraAutoFocusFaceModeSupported(callback: Callback) - override fun getAudioMixingPublishVolume(callback: Callback) { - callback.code(engine?.audioMixingPublishVolume) { it } - } + fun setCameraZoomFactor(params: Map, callback: Callback) - override fun getAudioMixingDuration(callback: Callback) { - callback.code(engine?.audioMixingDuration) { it } - } + fun getCameraMaxZoomFactor(callback: Callback) - override fun getAudioMixingCurrentPosition(callback: Callback) { - callback.code(engine?.audioMixingCurrentPosition) { it } - } + fun setCameraFocusPositionInPreview(params: Map, callback: Callback) - override fun setAudioMixingPosition(params: Map, callback: Callback) { - callback.code(engine?.setAudioMixingPosition((params["pos"] as Number).toInt())) - } + fun setCameraExposurePosition(params: Map, callback: Callback) - override fun setAudioMixingPitch(params: Map, callback: Callback) { - callback.code(engine?.setAudioMixingPitch((params["pitch"] as Number).toInt())) - } + fun enableFaceDetection(params: Map, callback: Callback) - override fun getEffectsVolume(callback: Callback) { - callback.resolve(engine) { it.audioEffectManager.effectsVolume } - } + fun setCameraTorchOn(params: Map, callback: Callback) - override fun setEffectsVolume(params: Map, callback: Callback) { - callback.code(engine?.audioEffectManager?.setEffectsVolume((params["volume"] as Number).toDouble())) - } + fun setCameraAutoFocusFaceModeEnabled(params: Map, callback: Callback) - override fun setVolumeOfEffect(params: Map, callback: Callback) { - callback.code(engine?.audioEffectManager?.setVolumeOfEffect((params["soundId"] as Number).toInt(), (params["volume"] as Number).toDouble())) - } + fun setCameraCapturerConfiguration(params: Map, callback: Callback) + } - override fun playEffect(params: Map, callback: Callback) { - callback.code(engine?.audioEffectManager?.playEffect((params["soundId"] as Number).toInt(), params["filePath"] as String, (params["loopCount"] as Number).toInt(), (params["pitch"] as Number).toDouble(), (params["pan"] as Number).toDouble(), (params["gain"] as Number).toDouble(), params["publish"] as Boolean)) - } + interface RtcStreamMessageInterface { + fun createDataStream(params: Map, callback: Callback) - override fun stopEffect(params: Map, callback: Callback) { - callback.code(engine?.audioEffectManager?.stopEffect((params["soundId"] as Number).toInt())) - } + fun sendStreamMessage(params: Map, callback: Callback) + } +} - override fun stopAllEffects(callback: Callback) { - callback.code(engine?.audioEffectManager?.stopAllEffects()) - } +class RtcEngineManager( + private val emit: (methodName: String, data: Map?) -> Unit +) : IRtcEngine.RtcEngineInterface { + var engine: RtcEngine? = null + private set + private var mediaObserver: MediaObserver? = null + + fun release() { + RtcEngine.destroy() + engine = null + mediaObserver = null + } + + override fun create(params: Map, callback: Callback) { + engine = RtcEngineEx.create(RtcEngineConfig().apply { + mContext = params["context"] as Context + mAppId = params["appId"] as String + mAreaCode = (params["areaCode"] as Number).toInt() + mEventHandler = RtcEngineEventHandler { methodName, data -> + emit(methodName, data) + } + }) + callback.code((engine as RtcEngineEx).setAppType((params["appType"] as Number).toInt())) + } + + override fun destroy(callback: Callback) { + callback.resolve(engine) { release() } + } + + override fun setChannelProfile(params: Map, callback: Callback) { + callback.code(engine?.setChannelProfile((params["profile"] as Number).toInt())) + } + + override fun setClientRole(params: Map, callback: Callback) { + callback.code(engine?.setClientRole((params["role"] as Number).toInt())) + } + + override fun joinChannel(params: Map, callback: Callback) { + callback.code(engine?.joinChannel(params["token"] as? String, params["channelName"] as String, params["optionalInfo"] as? String, (params["optionalUid"] as Number).toInt())) + } + + override fun switchChannel(params: Map, callback: Callback) { + callback.code(engine?.switchChannel(params["token"] as? String, params["channelName"] as String)) + } + + override fun leaveChannel(callback: Callback) { + callback.code(engine?.leaveChannel()) + } + + override fun renewToken(params: Map, callback: Callback) { + callback.code(engine?.renewToken(params["token"] as String)) + } + + override fun enableWebSdkInteroperability(params: Map, callback: Callback) { + callback.code(engine?.enableWebSdkInteroperability(params["enabled"] as Boolean)) + } + + override fun getConnectionState(callback: Callback) { + callback.resolve(engine) { it.connectionState } + } + + override fun sendCustomReportMessage(params: Map, callback: Callback) { + callback.code(engine?.sendCustomReportMessage(params["id"] as String, params["category"] as String, params["event"] as String, params["label"] as String, (params["value"] as Number).toInt())) + } + + override fun getCallId(callback: Callback) { + callback.resolve(engine) { it.callId } + } + + override fun rate(params: Map, callback: Callback) { + callback.code(engine?.rate(params["callId"] as String, (params["rating"] as Number).toInt(), params["description"] as? String)) + } + + override fun complain(params: Map, callback: Callback) { + callback.code(engine?.complain(params["callId"] as String, params["description"] as String)) + } + + override fun setLogFile(params: Map, callback: Callback) { + callback.code(engine?.setLogFile(params["filePath"] as String)) + } + + override fun setLogFilter(params: Map, callback: Callback) { + callback.code(engine?.setLogFilter((params["filter"] as Number).toInt())) + } + + override fun setLogFileSize(params: Map, callback: Callback) { + callback.code(engine?.setLogFileSize((params["fileSizeInKBytes"] as Number).toInt())) + } + + override fun setParameters(params: Map, callback: Callback) { + callback.code(engine?.setParameters(params["parameters"] as String)) + } + + override fun getNativeHandle(callback: Callback) { + callback.resolve(engine) { it.nativeHandle } + } + + override fun registerLocalUserAccount(params: Map, callback: Callback) { + callback.code(engine?.registerLocalUserAccount(params["appId"] as String, params["userAccount"] as String)) + } + + override fun joinChannelWithUserAccount(params: Map, callback: Callback) { + callback.code(engine?.joinChannelWithUserAccount(params["token"] as? String, params["channelName"] as String, params["userAccount"] as String)) + } + + override fun getUserInfoByUserAccount(params: Map, callback: Callback) { + callback.resolve(engine) { + val userInfo = UserInfo() + it.getUserInfoByUserAccount(params["userAccount"] as String, userInfo) + userInfo.toMap() + } + } + + override fun getUserInfoByUid(params: Map, callback: Callback) { + callback.resolve(engine) { + val userInfo = UserInfo() + it.getUserInfoByUid((params["uid"] as Number).toInt(), userInfo) + userInfo.toMap() + } + } - override fun preloadEffect(params: Map, callback: Callback) { - callback.code(engine?.audioEffectManager?.preloadEffect((params["soundId"] as Number).toInt(), params["filePath"] as String)) - } + override fun enableAudio(callback: Callback) { + callback.code(engine?.enableAudio()) + } - override fun unloadEffect(params: Map, callback: Callback) { - callback.code(engine?.audioEffectManager?.unloadEffect((params["soundId"] as Number).toInt())) - } + override fun disableAudio(callback: Callback) { + callback.code(engine?.disableAudio()) + } - override fun pauseEffect(params: Map, callback: Callback) { - callback.code(engine?.audioEffectManager?.pauseEffect((params["soundId"] as Number).toInt())) - } + override fun setAudioProfile(params: Map, callback: Callback) { + callback.code(engine?.setAudioProfile((params["profile"] as Number).toInt(), (params["scenario"] as Number).toInt())) + } - override fun pauseAllEffects(callback: Callback) { - callback.code(engine?.audioEffectManager?.pauseAllEffects()) - } + override fun adjustRecordingSignalVolume(params: Map, callback: Callback) { + callback.code(engine?.adjustRecordingSignalVolume((params["volume"] as Number).toInt())) + } - override fun resumeEffect(params: Map, callback: Callback) { - callback.code(engine?.audioEffectManager?.resumeEffect((params["soundId"] as Number).toInt())) - } + override fun adjustUserPlaybackSignalVolume(params: Map, callback: Callback) { + callback.code(engine?.adjustUserPlaybackSignalVolume((params["uid"] as Number).toInt(), (params["volume"] as Number).toInt())) + } - override fun resumeAllEffects(callback: Callback) { - callback.code(engine?.audioEffectManager?.resumeAllEffects()) - } + override fun adjustPlaybackSignalVolume(params: Map, callback: Callback) { + callback.code(engine?.adjustPlaybackSignalVolume((params["volume"] as Number).toInt())) + } - override fun setAudioSessionOperationRestriction(params: Map, callback: Callback) { - callback.code(-Constants.ERR_NOT_SUPPORTED) - } + override fun enableLocalAudio(params: Map, callback: Callback) { + callback.code(engine?.enableLocalAudio(params["enabled"] as Boolean)) + } - override fun setLocalVoiceChanger(params: Map, callback: Callback) { - callback.code(engine?.setLocalVoiceChanger((params["voiceChanger"] as Number).toInt())) - } + override fun muteLocalAudioStream(params: Map, callback: Callback) { + callback.code(engine?.muteLocalAudioStream(params["muted"] as Boolean)) + } - override fun setLocalVoiceReverbPreset(params: Map, callback: Callback) { - callback.code(engine?.setLocalVoiceReverbPreset((params["preset"] as Number).toInt())) - } + override fun muteRemoteAudioStream(params: Map, callback: Callback) { + callback.code(engine?.muteRemoteAudioStream((params["uid"] as Number).toInt(), params["muted"] as Boolean)) + } - override fun setLocalVoicePitch(params: Map, callback: Callback) { - callback.code(engine?.setLocalVoicePitch((params["pitch"] as Number).toDouble())) - } + override fun muteAllRemoteAudioStreams(params: Map, callback: Callback) { + callback.code(engine?.muteAllRemoteAudioStreams(params["muted"] as Boolean)) + } - override fun setLocalVoiceEqualization(params: Map, callback: Callback) { - callback.code(engine?.setLocalVoiceEqualization((params["bandFrequency"] as Number).toInt(), (params["bandGain"] as Number).toInt())) - } + override fun setDefaultMuteAllRemoteAudioStreams(params: Map, callback: Callback) { + callback.code(engine?.setDefaultMuteAllRemoteAudioStreams(params["muted"] as Boolean)) + } - override fun setLocalVoiceReverb(params: Map, callback: Callback) { - callback.code(engine?.setLocalVoiceReverb((params["reverbKey"] as Number).toInt(), (params["value"] as Number).toInt())) - } + override fun enableAudioVolumeIndication(params: Map, callback: Callback) { + callback.code(engine?.enableAudioVolumeIndication((params["interval"] as Number).toInt(), (params["smooth"] as Number).toInt(), params["report_vad"] as Boolean)) + } - override fun enableSoundPositionIndication(params: Map, callback: Callback) { - callback.code(engine?.enableSoundPositionIndication(params["enabled"] as Boolean)) - } + override fun enableVideo(callback: Callback) { + callback.code(engine?.enableVideo()) + } - override fun setRemoteVoicePosition(params: Map, callback: Callback) { - callback.code(engine?.setRemoteVoicePosition((params["uid"] as Number).toInt(), (params["pan"] as Number).toDouble(), (params["gain"] as Number).toDouble())) - } + override fun disableVideo(callback: Callback) { + callback.code(engine?.disableVideo()) + } - override fun setLiveTranscoding(params: Map, callback: Callback) { - callback.code(engine?.setLiveTranscoding(mapToLiveTranscoding(params["transcoding"] as Map<*, *>))) - } + override fun setVideoEncoderConfiguration(params: Map, callback: Callback) { + callback.code(engine?.setVideoEncoderConfiguration(mapToVideoEncoderConfiguration(params["config"] as Map<*, *>))) + } - override fun addPublishStreamUrl(params: Map, callback: Callback) { - callback.code(engine?.addPublishStreamUrl(params["url"] as String, params["transcodingEnabled"] as Boolean)) - } + override fun startPreview(callback: Callback) { + callback.code(engine?.startPreview()) + } - override fun removePublishStreamUrl(params: Map, callback: Callback) { - callback.code(engine?.removePublishStreamUrl(params["url"] as String)) - } + override fun stopPreview(callback: Callback) { + callback.code(engine?.stopPreview()) + } - override fun startChannelMediaRelay(params: Map, callback: Callback) { - callback.code(engine?.startChannelMediaRelay(mapToChannelMediaRelayConfiguration(params["channelMediaRelayConfiguration"] as Map<*, *>))) - } + override fun enableLocalVideo(params: Map, callback: Callback) { + callback.code(engine?.enableLocalVideo(params["enabled"] as Boolean)) + } - override fun updateChannelMediaRelay(params: Map, callback: Callback) { - callback.code(engine?.updateChannelMediaRelay(mapToChannelMediaRelayConfiguration(params["channelMediaRelayConfiguration"] as Map<*, *>))) - } + override fun muteLocalVideoStream(params: Map, callback: Callback) { + callback.code(engine?.muteLocalVideoStream(params["muted"] as Boolean)) + } - override fun stopChannelMediaRelay(callback: Callback) { - callback.code(engine?.stopChannelMediaRelay()) - } + override fun muteRemoteVideoStream(params: Map, callback: Callback) { + callback.code(engine?.muteRemoteVideoStream((params["uid"] as Number).toInt(), params["muted"] as Boolean)) + } - override fun setDefaultAudioRoutetoSpeakerphone(params: Map, callback: Callback) { - callback.code(engine?.setDefaultAudioRoutetoSpeakerphone(params["defaultToSpeaker"] as Boolean)) - } + override fun muteAllRemoteVideoStreams(params: Map, callback: Callback) { + callback.code(engine?.muteAllRemoteVideoStreams(params["muted"] as Boolean)) + } - override fun setEnableSpeakerphone(params: Map, callback: Callback) { - callback.code(engine?.setEnableSpeakerphone(params["enabled"] as Boolean)) - } + override fun setDefaultMuteAllRemoteVideoStreams(params: Map, callback: Callback) { + callback.code(engine?.setDefaultMuteAllRemoteVideoStreams(params["muted"] as Boolean)) + } - override fun isSpeakerphoneEnabled(callback: Callback) { - callback.resolve(engine) { it.isSpeakerphoneEnabled } - } + override fun setBeautyEffectOptions(params: Map, callback: Callback) { + callback.code(engine?.setBeautyEffectOptions(params["enabled"] as Boolean, mapToBeautyOptions(params["options"] as Map<*, *>))) + } - override fun enableInEarMonitoring(params: Map, callback: Callback) { - callback.code(engine?.enableInEarMonitoring(params["enabled"] as Boolean)) - } + override fun startAudioMixing(params: Map, callback: Callback) { + callback.code(engine?.startAudioMixing(params["filePath"] as String, params["loopback"] as Boolean, params["replace"] as Boolean, (params["cycle"] as Number).toInt())) + } - override fun setInEarMonitoringVolume(params: Map, callback: Callback) { - callback.code(engine?.setInEarMonitoringVolume((params["volume"] as Number).toInt())) - } + override fun stopAudioMixing(callback: Callback) { + callback.code(engine?.stopAudioMixing()) + } - override fun enableDualStreamMode(params: Map, callback: Callback) { - callback.code(engine?.enableDualStreamMode(params["enabled"] as Boolean)) - } + override fun pauseAudioMixing(callback: Callback) { + callback.code(engine?.pauseAudioMixing()) + } - override fun setRemoteVideoStreamType(params: Map, callback: Callback) { - callback.code(engine?.setRemoteVideoStreamType((params["uid"] as Number).toInt(), (params["streamType"] as Number).toInt())) - } + override fun resumeAudioMixing(callback: Callback) { + callback.code(engine?.resumeAudioMixing()) + } - override fun setRemoteDefaultVideoStreamType(params: Map, callback: Callback) { - callback.code(engine?.setRemoteDefaultVideoStreamType((params["streamType"] as Number).toInt())) - } + override fun adjustAudioMixingVolume(params: Map, callback: Callback) { + callback.code(engine?.adjustAudioMixingVolume((params["volume"] as Number).toInt())) + } - override fun setLocalPublishFallbackOption(params: Map, callback: Callback) { - callback.code(engine?.setLocalPublishFallbackOption((params["option"] as Number).toInt())) - } + override fun adjustAudioMixingPlayoutVolume(params: Map, callback: Callback) { + callback.code(engine?.adjustAudioMixingPlayoutVolume((params["volume"] as Number).toInt())) + } - override fun setRemoteSubscribeFallbackOption(params: Map, callback: Callback) { - callback.code(engine?.setRemoteSubscribeFallbackOption((params["option"] as Number).toInt())) - } + override fun adjustAudioMixingPublishVolume(params: Map, callback: Callback) { + callback.code(engine?.adjustAudioMixingPublishVolume((params["volume"] as Number).toInt())) + } - override fun setRemoteUserPriority(params: Map, callback: Callback) { - callback.code(engine?.setRemoteUserPriority((params["uid"] as Number).toInt(), (params["userPriority"] as Number).toInt())) - } + override fun getAudioMixingPlayoutVolume(callback: Callback) { + callback.code(engine?.audioMixingPlayoutVolume) { it } + } - override fun startEchoTest(params: Map, callback: Callback) { - callback.code(engine?.startEchoTest((params["intervalInSeconds"] as Number).toInt())) - } + override fun getAudioMixingPublishVolume(callback: Callback) { + callback.code(engine?.audioMixingPublishVolume) { it } + } - override fun stopEchoTest(callback: Callback) { - callback.code(engine?.stopEchoTest()) - } + override fun getAudioMixingDuration(callback: Callback) { + callback.code(engine?.audioMixingDuration) { it } + } - override fun enableLastmileTest(callback: Callback) { - callback.code(engine?.enableLastmileTest()) - } + override fun getAudioMixingCurrentPosition(callback: Callback) { + callback.code(engine?.audioMixingCurrentPosition) { it } + } - override fun disableLastmileTest(callback: Callback) { - callback.code(engine?.disableLastmileTest()) - } + override fun setAudioMixingPosition(params: Map, callback: Callback) { + callback.code(engine?.setAudioMixingPosition((params["pos"] as Number).toInt())) + } - override fun startLastmileProbeTest(params: Map, callback: Callback) { - callback.code(engine?.startLastmileProbeTest(mapToLastmileProbeConfig(params["config"] as Map<*, *>))) - } + override fun setAudioMixingPitch(params: Map, callback: Callback) { + callback.code(engine?.setAudioMixingPitch((params["pitch"] as Number).toInt())) + } - override fun stopLastmileProbeTest(callback: Callback) { - callback.code(engine?.stopLastmileProbeTest()) - } + override fun getEffectsVolume(callback: Callback) { + callback.resolve(engine) { it.audioEffectManager.effectsVolume } + } - override fun registerMediaMetadataObserver(callback: Callback) { - var code = -Constants.ERR_NOT_INITIALIZED - engine?.let { - val mediaObserver = MediaObserver { data -> - emit(RtcEngineEvents.MetadataReceived, data) - } - code = it.registerMediaMetadataObserver(mediaObserver, IMetadataObserver.VIDEO_METADATA) - if (code == 0) this.mediaObserver = mediaObserver - } - callback.code(code) - } + override fun setEffectsVolume(params: Map, callback: Callback) { + callback.code(engine?.audioEffectManager?.setEffectsVolume((params["volume"] as Number).toDouble())) + } - override fun unregisterMediaMetadataObserver(callback: Callback) { - var code = -Constants.ERR_NOT_INITIALIZED - engine?.let { - code = it.registerMediaMetadataObserver(null, IMetadataObserver.VIDEO_METADATA) - if (code == 0) mediaObserver = null - } - callback.code(code) - } + override fun setVolumeOfEffect(params: Map, callback: Callback) { + callback.code(engine?.audioEffectManager?.setVolumeOfEffect((params["soundId"] as Number).toInt(), (params["volume"] as Number).toDouble())) + } - override fun setMaxMetadataSize(params: Map, callback: Callback) { - callback.resolve(mediaObserver) { - it.maxMetadataSize = (params["size"] as Number).toInt() - Unit - } - } + override fun playEffect(params: Map, callback: Callback) { + callback.code(engine?.audioEffectManager?.playEffect((params["soundId"] as Number).toInt(), params["filePath"] as String, (params["loopCount"] as Number).toInt(), (params["pitch"] as Number).toDouble(), (params["pan"] as Number).toDouble(), (params["gain"] as Number).toDouble(), params["publish"] as Boolean)) + } - override fun sendMetadata(params: Map, callback: Callback) { - callback.resolve(mediaObserver) { - it.addMetadata(params["metadata"] as String) - } - } + override fun stopEffect(params: Map, callback: Callback) { + callback.code(engine?.audioEffectManager?.stopEffect((params["soundId"] as Number).toInt())) + } - override fun addVideoWatermark(params: Map, callback: Callback) { - callback.code(engine?.addVideoWatermark(params["watermarkUrl"] as String, mapToWatermarkOptions(params["options"] as Map<*, *>))) - } + override fun stopAllEffects(callback: Callback) { + callback.code(engine?.audioEffectManager?.stopAllEffects()) + } - override fun clearVideoWatermarks(callback: Callback) { - callback.code(engine?.clearVideoWatermarks()) - } + override fun preloadEffect(params: Map, callback: Callback) { + callback.code(engine?.audioEffectManager?.preloadEffect((params["soundId"] as Number).toInt(), params["filePath"] as String)) + } - override fun setEncryptionSecret(params: Map, callback: Callback) { - callback.code(engine?.setEncryptionSecret(params["secret"] as String)) - } + override fun unloadEffect(params: Map, callback: Callback) { + callback.code(engine?.audioEffectManager?.unloadEffect((params["soundId"] as Number).toInt())) + } - override fun setEncryptionMode(params: Map, callback: Callback) { - callback.code(engine?.setEncryptionMode(when ((params["encryptionMode"] as Number).toInt()) { - EncryptionConfig.EncryptionMode.AES_128_XTS.value -> "aes-128-xts" - EncryptionConfig.EncryptionMode.AES_128_ECB.value -> "aes-128-ecb" - EncryptionConfig.EncryptionMode.AES_256_XTS.value -> "aes-256-xts" - else -> "" - })) - } + override fun pauseEffect(params: Map, callback: Callback) { + callback.code(engine?.audioEffectManager?.pauseEffect((params["soundId"] as Number).toInt())) + } - override fun enableEncryption(params: Map, callback: Callback) { - callback.code(engine?.enableEncryption(params["enabled"] as Boolean, mapToEncryptionConfig(params["config"] as Map<*, *>))) - } + override fun pauseAllEffects(callback: Callback) { + callback.code(engine?.audioEffectManager?.pauseAllEffects()) + } - override fun startAudioRecording(params: Map, callback: Callback) { - callback.code(engine?.startAudioRecording(params["filePath"] as String, (params["sampleRate"] as Number).toInt(), (params["quality"] as Number).toInt())) - } + override fun resumeEffect(params: Map, callback: Callback) { + callback.code(engine?.audioEffectManager?.resumeEffect((params["soundId"] as Number).toInt())) + } - override fun stopAudioRecording(callback: Callback) { - callback.code(engine?.stopAudioRecording()) - } + override fun resumeAllEffects(callback: Callback) { + callback.code(engine?.audioEffectManager?.resumeAllEffects()) + } - override fun addInjectStreamUrl(params: Map, callback: Callback) { - callback.code(engine?.addInjectStreamUrl(params["url"] as String, mapToLiveInjectStreamConfig(params["config"] as Map<*, *>))) - } + override fun setAudioSessionOperationRestriction(params: Map, callback: Callback) { + callback.code(-Constants.ERR_NOT_SUPPORTED) + } - override fun removeInjectStreamUrl(params: Map, callback: Callback) { - callback.code(engine?.removeInjectStreamUrl(params["url"] as String)) - } + override fun setLocalVoiceChanger(params: Map, callback: Callback) { + callback.code(engine?.setLocalVoiceChanger((params["voiceChanger"] as Number).toInt())) + } - override fun switchCamera(callback: Callback) { - callback.code(engine?.switchCamera()) - } + override fun setLocalVoiceReverbPreset(params: Map, callback: Callback) { + callback.code(engine?.setLocalVoiceReverbPreset((params["preset"] as Number).toInt())) + } - override fun isCameraZoomSupported(callback: Callback) { - callback.resolve(engine) { it.isCameraZoomSupported } - } + override fun setLocalVoicePitch(params: Map, callback: Callback) { + callback.code(engine?.setLocalVoicePitch((params["pitch"] as Number).toDouble())) + } - override fun isCameraTorchSupported(callback: Callback) { - callback.resolve(engine) { it.isCameraTorchSupported } - } + override fun setLocalVoiceEqualization(params: Map, callback: Callback) { + callback.code(engine?.setLocalVoiceEqualization((params["bandFrequency"] as Number).toInt(), (params["bandGain"] as Number).toInt())) + } - override fun isCameraFocusSupported(callback: Callback) { - callback.resolve(engine) { it.isCameraFocusSupported } - } + override fun setLocalVoiceReverb(params: Map, callback: Callback) { + callback.code(engine?.setLocalVoiceReverb((params["reverbKey"] as Number).toInt(), (params["value"] as Number).toInt())) + } - override fun isCameraExposurePositionSupported(callback: Callback) { - callback.resolve(engine) { it.isCameraExposurePositionSupported } - } + override fun setAudioEffectPreset(params: Map, callback: Callback) { + callback.code(engine?.setAudioEffectPreset((params["preset"] as Number).toInt())) + } - override fun isCameraAutoFocusFaceModeSupported(callback: Callback) { - callback.resolve(engine) { it.isCameraAutoFocusFaceModeSupported } - } + override fun setVoiceBeautifierPreset(params: Map, callback: Callback) { + callback.code(engine?.setVoiceBeautifierPreset((params["preset"] as Number).toInt())) + } - override fun setCameraZoomFactor(params: Map, callback: Callback) { - callback.code(engine?.setCameraZoomFactor((params["factor"] as Number).toFloat())) - } + override fun setAudioEffectParameters(params: Map, callback: Callback) { + callback.code(engine?.setAudioEffectParameters((params["preset"] as Number).toInt(), (params["param1"] as Number).toInt(), (params["param2"] as Number).toInt())) + } - override fun getCameraMaxZoomFactor(callback: Callback) { - callback.resolve(engine) { it.cameraMaxZoomFactor } - } + override fun enableSoundPositionIndication(params: Map, callback: Callback) { + callback.code(engine?.enableSoundPositionIndication(params["enabled"] as Boolean)) + } - override fun setCameraFocusPositionInPreview(params: Map, callback: Callback) { - callback.code(engine?.setCameraFocusPositionInPreview((params["positionX"] as Number).toFloat(), (params["positionY"] as Number).toFloat())) - } + override fun setRemoteVoicePosition(params: Map, callback: Callback) { + callback.code(engine?.setRemoteVoicePosition((params["uid"] as Number).toInt(), (params["pan"] as Number).toDouble(), (params["gain"] as Number).toDouble())) + } + + override fun setLiveTranscoding(params: Map, callback: Callback) { + callback.code(engine?.setLiveTranscoding(mapToLiveTranscoding(params["transcoding"] as Map<*, *>))) + } - override fun setCameraExposurePosition(params: Map, callback: Callback) { - callback.code(engine?.setCameraExposurePosition((params["positionXinView"] as Number).toFloat(), (params["positionYinView"] as Number).toFloat())) - } + override fun addPublishStreamUrl(params: Map, callback: Callback) { + callback.code(engine?.addPublishStreamUrl(params["url"] as String, params["transcodingEnabled"] as Boolean)) + } + + override fun removePublishStreamUrl(params: Map, callback: Callback) { + callback.code(engine?.removePublishStreamUrl(params["url"] as String)) + } + + override fun startChannelMediaRelay(params: Map, callback: Callback) { + callback.code(engine?.startChannelMediaRelay(mapToChannelMediaRelayConfiguration(params["channelMediaRelayConfiguration"] as Map<*, *>))) + } + + override fun updateChannelMediaRelay(params: Map, callback: Callback) { + callback.code(engine?.updateChannelMediaRelay(mapToChannelMediaRelayConfiguration(params["channelMediaRelayConfiguration"] as Map<*, *>))) + } - override fun enableFaceDetection(params: Map, callback: Callback) { - callback.code(engine?.enableFaceDetection(params["enable"] as Boolean)) - } + override fun stopChannelMediaRelay(callback: Callback) { + callback.code(engine?.stopChannelMediaRelay()) + } - override fun setCameraTorchOn(params: Map, callback: Callback) { - callback.code(engine?.setCameraTorchOn(params["isOn"] as Boolean)) - } + override fun setDefaultAudioRoutetoSpeakerphone(params: Map, callback: Callback) { + callback.code(engine?.setDefaultAudioRoutetoSpeakerphone(params["defaultToSpeaker"] as Boolean)) + } - override fun setCameraAutoFocusFaceModeEnabled(params: Map, callback: Callback) { - callback.code(engine?.setCameraAutoFocusFaceModeEnabled(params["enabled"] as Boolean)) - } + override fun setEnableSpeakerphone(params: Map, callback: Callback) { + callback.code(engine?.setEnableSpeakerphone(params["enabled"] as Boolean)) + } - override fun setCameraCapturerConfiguration(params: Map, callback: Callback) { - callback.code(engine?.setCameraCapturerConfiguration(mapToCameraCapturerConfiguration(params["config"] as Map<*, *>))) - } + override fun isSpeakerphoneEnabled(callback: Callback) { + callback.resolve(engine) { it.isSpeakerphoneEnabled } + } - override fun createDataStream(params: Map, callback: Callback) { - var code = -Constants.ERR_NOT_INITIALIZED - engine?.let { - code = it.createDataStream(params["reliable"] as Boolean, params["ordered"] as Boolean) - } - callback.code(code) { it } - } + override fun enableInEarMonitoring(params: Map, callback: Callback) { + callback.code(engine?.enableInEarMonitoring(params["enabled"] as Boolean)) + } - override fun sendStreamMessage(params: Map, callback: Callback) { - var code = -Constants.ERR_NOT_INITIALIZED - engine?.let { - code = it.sendStreamMessage((params["streamId"] as Number).toInt(), (params["message"] as String).toByteArray()) - } - callback.code(code) - } + override fun setInEarMonitoringVolume(params: Map, callback: Callback) { + callback.code(engine?.setInEarMonitoringVolume((params["volume"] as Number).toInt())) + } + + override fun enableDualStreamMode(params: Map, callback: Callback) { + callback.code(engine?.enableDualStreamMode(params["enabled"] as Boolean)) + } + + override fun setRemoteVideoStreamType(params: Map, callback: Callback) { + callback.code(engine?.setRemoteVideoStreamType((params["uid"] as Number).toInt(), (params["streamType"] as Number).toInt())) + } + + override fun setRemoteDefaultVideoStreamType(params: Map, callback: Callback) { + callback.code(engine?.setRemoteDefaultVideoStreamType((params["streamType"] as Number).toInt())) + } + + override fun setLocalPublishFallbackOption(params: Map, callback: Callback) { + callback.code(engine?.setLocalPublishFallbackOption((params["option"] as Number).toInt())) + } + + override fun setRemoteSubscribeFallbackOption(params: Map, callback: Callback) { + callback.code(engine?.setRemoteSubscribeFallbackOption((params["option"] as Number).toInt())) + } + + override fun setRemoteUserPriority(params: Map, callback: Callback) { + callback.code(engine?.setRemoteUserPriority((params["uid"] as Number).toInt(), (params["userPriority"] as Number).toInt())) + } + + override fun startEchoTest(params: Map, callback: Callback) { + callback.code(engine?.startEchoTest((params["intervalInSeconds"] as Number).toInt())) + } + + override fun stopEchoTest(callback: Callback) { + callback.code(engine?.stopEchoTest()) + } + + override fun enableLastmileTest(callback: Callback) { + callback.code(engine?.enableLastmileTest()) + } + + override fun disableLastmileTest(callback: Callback) { + callback.code(engine?.disableLastmileTest()) + } + + override fun startLastmileProbeTest(params: Map, callback: Callback) { + callback.code(engine?.startLastmileProbeTest(mapToLastmileProbeConfig(params["config"] as Map<*, *>))) + } + + override fun stopLastmileProbeTest(callback: Callback) { + callback.code(engine?.stopLastmileProbeTest()) + } + + override fun registerMediaMetadataObserver(callback: Callback) { + var code = -Constants.ERR_NOT_INITIALIZED + engine?.let { + val mediaObserver = MediaObserver { data -> + emit(RtcEngineEvents.MetadataReceived, data) + } + code = it.registerMediaMetadataObserver(mediaObserver, IMetadataObserver.VIDEO_METADATA) + if (code == 0) this.mediaObserver = mediaObserver + } + callback.code(code) + } + + override fun unregisterMediaMetadataObserver(callback: Callback) { + var code = -Constants.ERR_NOT_INITIALIZED + engine?.let { + code = it.registerMediaMetadataObserver(null, IMetadataObserver.VIDEO_METADATA) + if (code == 0) mediaObserver = null + } + callback.code(code) + } + + override fun setMaxMetadataSize(params: Map, callback: Callback) { + callback.resolve(mediaObserver) { + it.maxMetadataSize = (params["size"] as Number).toInt() + Unit + } + } + + override fun sendMetadata(params: Map, callback: Callback) { + callback.resolve(mediaObserver) { + it.addMetadata(params["metadata"] as String) + } + } + + override fun addVideoWatermark(params: Map, callback: Callback) { + callback.code(engine?.addVideoWatermark(params["watermarkUrl"] as String, mapToWatermarkOptions(params["options"] as Map<*, *>))) + } + + override fun clearVideoWatermarks(callback: Callback) { + callback.code(engine?.clearVideoWatermarks()) + } + + override fun setEncryptionSecret(params: Map, callback: Callback) { + callback.code(engine?.setEncryptionSecret(params["secret"] as String)) + } + + override fun setEncryptionMode(params: Map, callback: Callback) { + callback.code(engine?.setEncryptionMode(when ((params["encryptionMode"] as Number).toInt()) { + EncryptionConfig.EncryptionMode.AES_128_XTS.value -> "aes-128-xts" + EncryptionConfig.EncryptionMode.AES_128_ECB.value -> "aes-128-ecb" + EncryptionConfig.EncryptionMode.AES_256_XTS.value -> "aes-256-xts" + else -> "" + })) + } + + override fun enableEncryption(params: Map, callback: Callback) { + callback.code(engine?.enableEncryption(params["enabled"] as Boolean, mapToEncryptionConfig(params["config"] as Map<*, *>))) + } + + override fun startAudioRecording(params: Map, callback: Callback) { + callback.code(engine?.startAudioRecording(params["filePath"] as String, (params["sampleRate"] as Number).toInt(), (params["quality"] as Number).toInt())) + } + + override fun stopAudioRecording(callback: Callback) { + callback.code(engine?.stopAudioRecording()) + } + + override fun addInjectStreamUrl(params: Map, callback: Callback) { + callback.code(engine?.addInjectStreamUrl(params["url"] as String, mapToLiveInjectStreamConfig(params["config"] as Map<*, *>))) + } + + override fun removeInjectStreamUrl(params: Map, callback: Callback) { + callback.code(engine?.removeInjectStreamUrl(params["url"] as String)) + } + + override fun switchCamera(callback: Callback) { + callback.code(engine?.switchCamera()) + } + + override fun isCameraZoomSupported(callback: Callback) { + callback.resolve(engine) { it.isCameraZoomSupported } + } + + override fun isCameraTorchSupported(callback: Callback) { + callback.resolve(engine) { it.isCameraTorchSupported } + } + + override fun isCameraFocusSupported(callback: Callback) { + callback.resolve(engine) { it.isCameraFocusSupported } + } + + override fun isCameraExposurePositionSupported(callback: Callback) { + callback.resolve(engine) { it.isCameraExposurePositionSupported } + } + + override fun isCameraAutoFocusFaceModeSupported(callback: Callback) { + callback.resolve(engine) { it.isCameraAutoFocusFaceModeSupported } + } + + override fun setCameraZoomFactor(params: Map, callback: Callback) { + callback.code(engine?.setCameraZoomFactor((params["factor"] as Number).toFloat())) + } + + override fun getCameraMaxZoomFactor(callback: Callback) { + callback.resolve(engine) { it.cameraMaxZoomFactor } + } + + override fun setCameraFocusPositionInPreview(params: Map, callback: Callback) { + callback.code(engine?.setCameraFocusPositionInPreview((params["positionX"] as Number).toFloat(), (params["positionY"] as Number).toFloat())) + } + + override fun setCameraExposurePosition(params: Map, callback: Callback) { + callback.code(engine?.setCameraExposurePosition((params["positionXinView"] as Number).toFloat(), (params["positionYinView"] as Number).toFloat())) + } + + override fun enableFaceDetection(params: Map, callback: Callback) { + callback.code(engine?.enableFaceDetection(params["enable"] as Boolean)) + } + + override fun setCameraTorchOn(params: Map, callback: Callback) { + callback.code(engine?.setCameraTorchOn(params["isOn"] as Boolean)) + } + + override fun setCameraAutoFocusFaceModeEnabled(params: Map, callback: Callback) { + callback.code(engine?.setCameraAutoFocusFaceModeEnabled(params["enabled"] as Boolean)) + } + + override fun setCameraCapturerConfiguration(params: Map, callback: Callback) { + callback.code(engine?.setCameraCapturerConfiguration(mapToCameraCapturerConfiguration(params["config"] as Map<*, *>))) + } + + override fun createDataStream(params: Map, callback: Callback) { + var code = -Constants.ERR_NOT_INITIALIZED + engine?.let { + code = it.createDataStream(params["reliable"] as Boolean, params["ordered"] as Boolean) + } + callback.code(code) { it } + } + + override fun sendStreamMessage(params: Map, callback: Callback) { + var code = -Constants.ERR_NOT_INITIALIZED + engine?.let { + code = it.sendStreamMessage((params["streamId"] as Number).toInt(), (params["message"] as String).toByteArray()) + } + callback.code(code) + } } diff --git a/RtcEngineEvent.kt b/RtcEngineEvent.kt index 767f2c31a..553446afd 100644 --- a/RtcEngineEvent.kt +++ b/RtcEngineEvent.kt @@ -6,510 +6,510 @@ import io.agora.rtc.IRtcEngineEventHandler import io.agora.rtc.models.UserInfo class RtcEngineEvents { - companion object { - const val Warning = "Warning" - const val Error = "Error" - const val ApiCallExecuted = "ApiCallExecuted" - const val JoinChannelSuccess = "JoinChannelSuccess" - const val RejoinChannelSuccess = "RejoinChannelSuccess" - const val LeaveChannel = "LeaveChannel" - const val LocalUserRegistered = "LocalUserRegistered" - const val UserInfoUpdated = "UserInfoUpdated" - const val ClientRoleChanged = "ClientRoleChanged" - const val UserJoined = "UserJoined" - const val UserOffline = "UserOffline" - const val ConnectionStateChanged = "ConnectionStateChanged" - const val NetworkTypeChanged = "NetworkTypeChanged" - const val ConnectionLost = "ConnectionLost" - const val TokenPrivilegeWillExpire = "TokenPrivilegeWillExpire" - const val RequestToken = "RequestToken" - const val AudioVolumeIndication = "AudioVolumeIndication" - const val ActiveSpeaker = "ActiveSpeaker" - const val FirstLocalAudioFrame = "FirstLocalAudioFrame" - const val FirstLocalVideoFrame = "FirstLocalVideoFrame" - const val UserMuteVideo = "UserMuteVideo" - const val VideoSizeChanged = "VideoSizeChanged" - const val RemoteVideoStateChanged = "RemoteVideoStateChanged" - const val LocalVideoStateChanged = "LocalVideoStateChanged" - const val RemoteAudioStateChanged = "RemoteAudioStateChanged" - const val LocalAudioStateChanged = "LocalAudioStateChanged" - const val LocalPublishFallbackToAudioOnly = "LocalPublishFallbackToAudioOnly" - const val RemoteSubscribeFallbackToAudioOnly = "RemoteSubscribeFallbackToAudioOnly" - const val AudioRouteChanged = "AudioRouteChanged" - const val CameraFocusAreaChanged = "CameraFocusAreaChanged" - const val CameraExposureAreaChanged = "CameraExposureAreaChanged" - const val FacePositionChanged = "FacePositionChanged" - const val RtcStats = "RtcStats" - const val LastmileQuality = "LastmileQuality" - const val NetworkQuality = "NetworkQuality" - const val LastmileProbeResult = "LastmileProbeResult" - const val LocalVideoStats = "LocalVideoStats" - const val LocalAudioStats = "LocalAudioStats" - const val RemoteVideoStats = "RemoteVideoStats" - const val RemoteAudioStats = "RemoteAudioStats" - const val AudioMixingFinished = "AudioMixingFinished" - const val AudioMixingStateChanged = "AudioMixingStateChanged" - const val AudioEffectFinished = "AudioEffectFinished" - const val RtmpStreamingStateChanged = "RtmpStreamingStateChanged" - const val TranscodingUpdated = "TranscodingUpdated" - const val StreamInjectedStatus = "StreamInjectedStatus" - const val StreamMessage = "StreamMessage" - const val StreamMessageError = "StreamMessageError" - const val MediaEngineLoadSuccess = "MediaEngineLoadSuccess" - const val MediaEngineStartCallSuccess = "MediaEngineStartCallSuccess" - const val ChannelMediaRelayStateChanged = "ChannelMediaRelayStateChanged" - const val ChannelMediaRelayEvent = "ChannelMediaRelayEvent" - const val FirstRemoteVideoFrame = "FirstRemoteVideoFrame" - const val FirstRemoteAudioFrame = "FirstRemoteAudioFrame" - const val FirstRemoteAudioDecoded = "FirstRemoteAudioDecoded" - const val UserMuteAudio = "UserMuteAudio" - const val StreamPublished = "StreamPublished" - const val StreamUnpublished = "StreamUnpublished" - const val RemoteAudioTransportStats = "RemoteAudioTransportStats" - const val RemoteVideoTransportStats = "RemoteVideoTransportStats" - const val UserEnableVideo = "UserEnableVideo" - const val UserEnableLocalVideo = "UserEnableLocalVideo" - const val FirstRemoteVideoDecoded = "FirstRemoteVideoDecoded" - const val MicrophoneEnabled = "MicrophoneEnabled" - const val ConnectionInterrupted = "ConnectionInterrupted" - const val ConnectionBanned = "ConnectionBanned" - const val AudioQuality = "AudioQuality" - const val CameraReady = "CameraReady" - const val VideoStopped = "VideoStopped" - const val MetadataReceived = "MetadataReceived" - const val FirstLocalAudioFramePublished = "FirstLocalAudioFramePublished" - const val FirstLocalVideoFramePublished = "FirstLocalVideoFramePublished" - const val AudioPublishStateChanged = "AudioPublishStateChanged" - const val VideoPublishStateChanged = "VideoPublishStateChanged" - const val AudioSubscribeStateChanged = "AudioSubscribeStateChanged" - const val VideoSubscribeStateChanged = "VideoSubscribeStateChanged" - const val RtmpStreamingEvent = "RtmpStreamingEvent" - - fun toMap(): Map { - return hashMapOf( - "Warning" to Warning, - "Error" to Error, - "ApiCallExecuted" to ApiCallExecuted, - "JoinChannelSuccess" to JoinChannelSuccess, - "RejoinChannelSuccess" to RejoinChannelSuccess, - "LeaveChannel" to LeaveChannel, - "LocalUserRegistered" to LocalUserRegistered, - "UserInfoUpdated" to UserInfoUpdated, - "ClientRoleChanged" to ClientRoleChanged, - "UserJoined" to UserJoined, - "UserOffline" to UserOffline, - "ConnectionStateChanged" to ConnectionStateChanged, - "NetworkTypeChanged" to NetworkTypeChanged, - "ConnectionLost" to ConnectionLost, - "TokenPrivilegeWillExpire" to TokenPrivilegeWillExpire, - "RequestToken" to RequestToken, - "AudioVolumeIndication" to AudioVolumeIndication, - "ActiveSpeaker" to ActiveSpeaker, - "FirstLocalAudioFrame" to FirstLocalAudioFrame, - "FirstLocalVideoFrame" to FirstLocalVideoFrame, - "UserMuteVideo" to UserMuteVideo, - "VideoSizeChanged" to VideoSizeChanged, - "RemoteVideoStateChanged" to RemoteVideoStateChanged, - "LocalVideoStateChanged" to LocalVideoStateChanged, - "RemoteAudioStateChanged" to RemoteAudioStateChanged, - "LocalAudioStateChanged" to LocalAudioStateChanged, - "LocalPublishFallbackToAudioOnly" to LocalPublishFallbackToAudioOnly, - "RemoteSubscribeFallbackToAudioOnly" to RemoteSubscribeFallbackToAudioOnly, - "AudioRouteChanged" to AudioRouteChanged, - "CameraFocusAreaChanged" to CameraFocusAreaChanged, - "CameraExposureAreaChanged" to CameraExposureAreaChanged, - "FacePositionChanged" to FacePositionChanged, - "RtcStats" to RtcStats, - "LastmileQuality" to LastmileQuality, - "NetworkQuality" to NetworkQuality, - "LastmileProbeResult" to LastmileProbeResult, - "LocalVideoStats" to LocalVideoStats, - "LocalAudioStats" to LocalAudioStats, - "RemoteVideoStats" to RemoteVideoStats, - "RemoteAudioStats" to RemoteAudioStats, - "AudioMixingFinished" to AudioMixingFinished, - "AudioMixingStateChanged" to AudioMixingStateChanged, - "AudioEffectFinished" to AudioEffectFinished, - "RtmpStreamingStateChanged" to RtmpStreamingStateChanged, - "TranscodingUpdated" to TranscodingUpdated, - "StreamInjectedStatus" to StreamInjectedStatus, - "StreamMessage" to StreamMessage, - "StreamMessageError" to StreamMessageError, - "MediaEngineLoadSuccess" to MediaEngineLoadSuccess, - "MediaEngineStartCallSuccess" to MediaEngineStartCallSuccess, - "ChannelMediaRelayStateChanged" to ChannelMediaRelayStateChanged, - "ChannelMediaRelayEvent" to ChannelMediaRelayEvent, - "FirstRemoteVideoFrame" to FirstRemoteVideoFrame, - "FirstRemoteAudioFrame" to FirstRemoteAudioFrame, - "FirstRemoteAudioDecoded" to FirstRemoteAudioDecoded, - "UserMuteAudio" to UserMuteAudio, - "StreamPublished" to StreamPublished, - "StreamUnpublished" to StreamUnpublished, - "RemoteAudioTransportStats" to RemoteAudioTransportStats, - "RemoteVideoTransportStats" to RemoteVideoTransportStats, - "UserEnableVideo" to UserEnableVideo, - "UserEnableLocalVideo" to UserEnableLocalVideo, - "FirstRemoteVideoDecoded" to FirstRemoteVideoDecoded, - "MicrophoneEnabled" to MicrophoneEnabled, - "ConnectionInterrupted" to ConnectionInterrupted, - "ConnectionBanned" to ConnectionBanned, - "AudioQuality" to AudioQuality, - "CameraReady" to CameraReady, - "VideoStopped" to VideoStopped, - "MetadataReceived" to MetadataReceived, - "FirstLocalAudioFramePublished" to FirstLocalAudioFramePublished, - "FirstLocalVideoFramePublished" to FirstLocalVideoFramePublished, - "AudioPublishStateChanged" to AudioPublishStateChanged, - "VideoPublishStateChanged" to VideoPublishStateChanged, - "AudioSubscribeStateChanged" to AudioSubscribeStateChanged, - "VideoSubscribeStateChanged" to VideoSubscribeStateChanged, - "RtmpStreamingEvent" to RtmpStreamingEvent - ) - } - } + companion object { + const val Warning = "Warning" + const val Error = "Error" + const val ApiCallExecuted = "ApiCallExecuted" + const val JoinChannelSuccess = "JoinChannelSuccess" + const val RejoinChannelSuccess = "RejoinChannelSuccess" + const val LeaveChannel = "LeaveChannel" + const val LocalUserRegistered = "LocalUserRegistered" + const val UserInfoUpdated = "UserInfoUpdated" + const val ClientRoleChanged = "ClientRoleChanged" + const val UserJoined = "UserJoined" + const val UserOffline = "UserOffline" + const val ConnectionStateChanged = "ConnectionStateChanged" + const val NetworkTypeChanged = "NetworkTypeChanged" + const val ConnectionLost = "ConnectionLost" + const val TokenPrivilegeWillExpire = "TokenPrivilegeWillExpire" + const val RequestToken = "RequestToken" + const val AudioVolumeIndication = "AudioVolumeIndication" + const val ActiveSpeaker = "ActiveSpeaker" + const val FirstLocalAudioFrame = "FirstLocalAudioFrame" + const val FirstLocalVideoFrame = "FirstLocalVideoFrame" + const val UserMuteVideo = "UserMuteVideo" + const val VideoSizeChanged = "VideoSizeChanged" + const val RemoteVideoStateChanged = "RemoteVideoStateChanged" + const val LocalVideoStateChanged = "LocalVideoStateChanged" + const val RemoteAudioStateChanged = "RemoteAudioStateChanged" + const val LocalAudioStateChanged = "LocalAudioStateChanged" + const val LocalPublishFallbackToAudioOnly = "LocalPublishFallbackToAudioOnly" + const val RemoteSubscribeFallbackToAudioOnly = "RemoteSubscribeFallbackToAudioOnly" + const val AudioRouteChanged = "AudioRouteChanged" + const val CameraFocusAreaChanged = "CameraFocusAreaChanged" + const val CameraExposureAreaChanged = "CameraExposureAreaChanged" + const val FacePositionChanged = "FacePositionChanged" + const val RtcStats = "RtcStats" + const val LastmileQuality = "LastmileQuality" + const val NetworkQuality = "NetworkQuality" + const val LastmileProbeResult = "LastmileProbeResult" + const val LocalVideoStats = "LocalVideoStats" + const val LocalAudioStats = "LocalAudioStats" + const val RemoteVideoStats = "RemoteVideoStats" + const val RemoteAudioStats = "RemoteAudioStats" + const val AudioMixingFinished = "AudioMixingFinished" + const val AudioMixingStateChanged = "AudioMixingStateChanged" + const val AudioEffectFinished = "AudioEffectFinished" + const val RtmpStreamingStateChanged = "RtmpStreamingStateChanged" + const val TranscodingUpdated = "TranscodingUpdated" + const val StreamInjectedStatus = "StreamInjectedStatus" + const val StreamMessage = "StreamMessage" + const val StreamMessageError = "StreamMessageError" + const val MediaEngineLoadSuccess = "MediaEngineLoadSuccess" + const val MediaEngineStartCallSuccess = "MediaEngineStartCallSuccess" + const val ChannelMediaRelayStateChanged = "ChannelMediaRelayStateChanged" + const val ChannelMediaRelayEvent = "ChannelMediaRelayEvent" + const val FirstRemoteVideoFrame = "FirstRemoteVideoFrame" + const val FirstRemoteAudioFrame = "FirstRemoteAudioFrame" + const val FirstRemoteAudioDecoded = "FirstRemoteAudioDecoded" + const val UserMuteAudio = "UserMuteAudio" + const val StreamPublished = "StreamPublished" + const val StreamUnpublished = "StreamUnpublished" + const val RemoteAudioTransportStats = "RemoteAudioTransportStats" + const val RemoteVideoTransportStats = "RemoteVideoTransportStats" + const val UserEnableVideo = "UserEnableVideo" + const val UserEnableLocalVideo = "UserEnableLocalVideo" + const val FirstRemoteVideoDecoded = "FirstRemoteVideoDecoded" + const val MicrophoneEnabled = "MicrophoneEnabled" + const val ConnectionInterrupted = "ConnectionInterrupted" + const val ConnectionBanned = "ConnectionBanned" + const val AudioQuality = "AudioQuality" + const val CameraReady = "CameraReady" + const val VideoStopped = "VideoStopped" + const val MetadataReceived = "MetadataReceived" + const val FirstLocalAudioFramePublished = "FirstLocalAudioFramePublished" + const val FirstLocalVideoFramePublished = "FirstLocalVideoFramePublished" + const val AudioPublishStateChanged = "AudioPublishStateChanged" + const val VideoPublishStateChanged = "VideoPublishStateChanged" + const val AudioSubscribeStateChanged = "AudioSubscribeStateChanged" + const val VideoSubscribeStateChanged = "VideoSubscribeStateChanged" + const val RtmpStreamingEvent = "RtmpStreamingEvent" + + fun toMap(): Map { + return hashMapOf( + "Warning" to Warning, + "Error" to Error, + "ApiCallExecuted" to ApiCallExecuted, + "JoinChannelSuccess" to JoinChannelSuccess, + "RejoinChannelSuccess" to RejoinChannelSuccess, + "LeaveChannel" to LeaveChannel, + "LocalUserRegistered" to LocalUserRegistered, + "UserInfoUpdated" to UserInfoUpdated, + "ClientRoleChanged" to ClientRoleChanged, + "UserJoined" to UserJoined, + "UserOffline" to UserOffline, + "ConnectionStateChanged" to ConnectionStateChanged, + "NetworkTypeChanged" to NetworkTypeChanged, + "ConnectionLost" to ConnectionLost, + "TokenPrivilegeWillExpire" to TokenPrivilegeWillExpire, + "RequestToken" to RequestToken, + "AudioVolumeIndication" to AudioVolumeIndication, + "ActiveSpeaker" to ActiveSpeaker, + "FirstLocalAudioFrame" to FirstLocalAudioFrame, + "FirstLocalVideoFrame" to FirstLocalVideoFrame, + "UserMuteVideo" to UserMuteVideo, + "VideoSizeChanged" to VideoSizeChanged, + "RemoteVideoStateChanged" to RemoteVideoStateChanged, + "LocalVideoStateChanged" to LocalVideoStateChanged, + "RemoteAudioStateChanged" to RemoteAudioStateChanged, + "LocalAudioStateChanged" to LocalAudioStateChanged, + "LocalPublishFallbackToAudioOnly" to LocalPublishFallbackToAudioOnly, + "RemoteSubscribeFallbackToAudioOnly" to RemoteSubscribeFallbackToAudioOnly, + "AudioRouteChanged" to AudioRouteChanged, + "CameraFocusAreaChanged" to CameraFocusAreaChanged, + "CameraExposureAreaChanged" to CameraExposureAreaChanged, + "FacePositionChanged" to FacePositionChanged, + "RtcStats" to RtcStats, + "LastmileQuality" to LastmileQuality, + "NetworkQuality" to NetworkQuality, + "LastmileProbeResult" to LastmileProbeResult, + "LocalVideoStats" to LocalVideoStats, + "LocalAudioStats" to LocalAudioStats, + "RemoteVideoStats" to RemoteVideoStats, + "RemoteAudioStats" to RemoteAudioStats, + "AudioMixingFinished" to AudioMixingFinished, + "AudioMixingStateChanged" to AudioMixingStateChanged, + "AudioEffectFinished" to AudioEffectFinished, + "RtmpStreamingStateChanged" to RtmpStreamingStateChanged, + "TranscodingUpdated" to TranscodingUpdated, + "StreamInjectedStatus" to StreamInjectedStatus, + "StreamMessage" to StreamMessage, + "StreamMessageError" to StreamMessageError, + "MediaEngineLoadSuccess" to MediaEngineLoadSuccess, + "MediaEngineStartCallSuccess" to MediaEngineStartCallSuccess, + "ChannelMediaRelayStateChanged" to ChannelMediaRelayStateChanged, + "ChannelMediaRelayEvent" to ChannelMediaRelayEvent, + "FirstRemoteVideoFrame" to FirstRemoteVideoFrame, + "FirstRemoteAudioFrame" to FirstRemoteAudioFrame, + "FirstRemoteAudioDecoded" to FirstRemoteAudioDecoded, + "UserMuteAudio" to UserMuteAudio, + "StreamPublished" to StreamPublished, + "StreamUnpublished" to StreamUnpublished, + "RemoteAudioTransportStats" to RemoteAudioTransportStats, + "RemoteVideoTransportStats" to RemoteVideoTransportStats, + "UserEnableVideo" to UserEnableVideo, + "UserEnableLocalVideo" to UserEnableLocalVideo, + "FirstRemoteVideoDecoded" to FirstRemoteVideoDecoded, + "MicrophoneEnabled" to MicrophoneEnabled, + "ConnectionInterrupted" to ConnectionInterrupted, + "ConnectionBanned" to ConnectionBanned, + "AudioQuality" to AudioQuality, + "CameraReady" to CameraReady, + "VideoStopped" to VideoStopped, + "MetadataReceived" to MetadataReceived, + "FirstLocalAudioFramePublished" to FirstLocalAudioFramePublished, + "FirstLocalVideoFramePublished" to FirstLocalVideoFramePublished, + "AudioPublishStateChanged" to AudioPublishStateChanged, + "VideoPublishStateChanged" to VideoPublishStateChanged, + "AudioSubscribeStateChanged" to AudioSubscribeStateChanged, + "VideoSubscribeStateChanged" to VideoSubscribeStateChanged, + "RtmpStreamingEvent" to RtmpStreamingEvent + ) + } + } } class RtcEngineEventHandler( - private val emitter: (methodName: String, data: Map?) -> Unit + private val emitter: (methodName: String, data: Map?) -> Unit ) : IRtcEngineEventHandler() { - companion object { - const val PREFIX = "io.agora.rtc." - } - - private fun callback(methodName: String, vararg data: Any?) { - emitter(methodName, hashMapOf("data" to data.toList())) - } - - override fun onWarning(@Annotations.AgoraWarningCode warn: Int) { - callback(RtcEngineEvents.Warning, warn) - } - - override fun onError(@Annotations.AgoraErrorCode err: Int) { - callback(RtcEngineEvents.Error, err) - } - - override fun onApiCallExecuted(@Annotations.AgoraErrorCode error: Int, api: String?, result: String?) { - callback(RtcEngineEvents.ApiCallExecuted, error, api, result) - } - - override fun onJoinChannelSuccess(channel: String?, uid: Int, elapsed: Int) { - callback(RtcEngineEvents.JoinChannelSuccess, channel, uid, elapsed) - } - - override fun onRejoinChannelSuccess(channel: String?, uid: Int, elapsed: Int) { - callback(RtcEngineEvents.RejoinChannelSuccess, channel, uid, elapsed) - } - - override fun onLeaveChannel(stats: RtcStats?) { - callback(RtcEngineEvents.LeaveChannel, stats?.toMap()) - } - - override fun onLocalUserRegistered(uid: Int, userAccount: String?) { - callback(RtcEngineEvents.LocalUserRegistered, uid, userAccount) - } - - override fun onUserInfoUpdated(uid: Int, userInfo: UserInfo?) { - callback(RtcEngineEvents.UserInfoUpdated, uid, userInfo?.toMap()) - } - - override fun onClientRoleChanged(@Annotations.AgoraClientRole oldRole: Int, @Annotations.AgoraClientRole newRole: Int) { - callback(RtcEngineEvents.ClientRoleChanged, oldRole, newRole) - } - - override fun onUserJoined(uid: Int, elapsed: Int) { - callback(RtcEngineEvents.UserJoined, uid, elapsed) - } - - override fun onUserOffline(uid: Int, @Annotations.AgoraUserOfflineReason reason: Int) { - callback(RtcEngineEvents.UserOffline, uid, reason) - } - - override fun onConnectionStateChanged(@Annotations.AgoraConnectionStateType state: Int, @Annotations.AgoraConnectionChangedReason reason: Int) { - callback(RtcEngineEvents.ConnectionStateChanged, state, reason) - } - - override fun onNetworkTypeChanged(@Annotations.AgoraNetworkType type: Int) { - callback(RtcEngineEvents.NetworkTypeChanged, type) - } - - override fun onConnectionLost() { - callback(RtcEngineEvents.ConnectionLost) - } - - override fun onTokenPrivilegeWillExpire(token: String?) { - callback(RtcEngineEvents.TokenPrivilegeWillExpire, token) - } - - override fun onRequestToken() { - callback(RtcEngineEvents.RequestToken) - } - - override fun onAudioVolumeIndication(speakers: Array?, @IntRange(from = 0, to = 255) totalVolume: Int) { - callback(RtcEngineEvents.AudioVolumeIndication, speakers?.toMapList(), totalVolume) - } - - override fun onActiveSpeaker(uid: Int) { - callback(RtcEngineEvents.ActiveSpeaker, uid) - } - - override fun onFirstLocalAudioFrame(elapsed: Int) { - callback(RtcEngineEvents.FirstLocalAudioFrame, elapsed) - } - - override fun onFirstLocalVideoFrame(width: Int, height: Int, elapsed: Int) { - callback(RtcEngineEvents.FirstLocalVideoFrame, width, height, elapsed) - } - - @Deprecated("", ReplaceWith("onRemoteVideoStateChanged")) - override fun onUserMuteVideo(uid: Int, muted: Boolean) { - callback(RtcEngineEvents.UserMuteVideo, uid, muted) - } - - override fun onVideoSizeChanged(uid: Int, width: Int, height: Int, @IntRange(from = 0, to = 360) rotation: Int) { - callback(RtcEngineEvents.VideoSizeChanged, uid, width, height, rotation) - } - - override fun onRemoteVideoStateChanged(uid: Int, @Annotations.AgoraVideoRemoteState state: Int, @Annotations.AgoraVideoRemoteStateReason reason: Int, elapsed: Int) { - callback(RtcEngineEvents.RemoteVideoStateChanged, uid, state, reason, elapsed) - } - - override fun onLocalVideoStateChanged(@Annotations.AgoraLocalVideoStreamState localVideoState: Int, @Annotations.AgoraLocalVideoStreamError error: Int) { - callback(RtcEngineEvents.LocalVideoStateChanged, localVideoState, error) - } - - override fun onRemoteAudioStateChanged(uid: Int, @Annotations.AgoraAudioRemoteState state: Int, @Annotations.AgoraAudioRemoteStateReason reason: Int, elapsed: Int) { - callback(RtcEngineEvents.RemoteAudioStateChanged, uid, state, reason, elapsed) - } - - override fun onLocalAudioStateChanged(@Annotations.AgoraAudioLocalState state: Int, @Annotations.AgoraAudioLocalError error: Int) { - callback(RtcEngineEvents.LocalAudioStateChanged, state, error) - } - - override fun onLocalPublishFallbackToAudioOnly(isFallbackOrRecover: Boolean) { - callback(RtcEngineEvents.LocalPublishFallbackToAudioOnly, isFallbackOrRecover) - } - - override fun onRemoteSubscribeFallbackToAudioOnly(uid: Int, isFallbackOrRecover: Boolean) { - callback(RtcEngineEvents.RemoteSubscribeFallbackToAudioOnly, uid, isFallbackOrRecover) - } - - override fun onAudioRouteChanged(@Annotations.AgoraAudioOutputRouting routing: Int) { - callback(RtcEngineEvents.AudioRouteChanged, routing) - } - - override fun onCameraFocusAreaChanged(rect: Rect?) { - callback(RtcEngineEvents.CameraFocusAreaChanged, rect?.toMap()) - } - - override fun onCameraExposureAreaChanged(rect: Rect?) { - callback(RtcEngineEvents.CameraExposureAreaChanged, rect?.toMap()) - } - - override fun onFacePositionChanged(imageWidth: Int, imageHeight: Int, faces: Array?) { - callback(RtcEngineEvents.FacePositionChanged, imageWidth, imageHeight, faces?.toMapList()) - } - - override fun onRtcStats(stats: RtcStats?) { - callback(RtcEngineEvents.RtcStats, stats?.toMap()) - } - - override fun onLastmileQuality(@Annotations.AgoraNetworkQuality quality: Int) { - callback(RtcEngineEvents.LastmileQuality, quality) - } - - override fun onNetworkQuality(uid: Int, @Annotations.AgoraNetworkQuality txQuality: Int, @Annotations.AgoraNetworkQuality rxQuality: Int) { - callback(RtcEngineEvents.NetworkQuality, uid, txQuality, rxQuality) - } - - override fun onLastmileProbeResult(result: LastmileProbeResult?) { - callback(RtcEngineEvents.LastmileProbeResult, result?.toMap()) - } - - @Deprecated("", ReplaceWith("onLocalVideoStats")) - override fun onLocalVideoStat(sentBitrate: Int, sentFrameRate: Int) { - // TODO Not in iOS - } - - override fun onLocalVideoStats(stats: LocalVideoStats?) { - callback(RtcEngineEvents.LocalVideoStats, stats?.toMap()) - } - - override fun onLocalAudioStats(stats: LocalAudioStats?) { - callback(RtcEngineEvents.LocalAudioStats, stats?.toMap()) - } - - @Deprecated("", ReplaceWith("onRemoteVideoStats")) - override fun onRemoteVideoStat(uid: Int, delay: Int, receivedBitrate: Int, receivedFrameRate: Int) { - // TODO Not in iOS - } - - override fun onRemoteVideoStats(stats: RemoteVideoStats?) { - callback(RtcEngineEvents.RemoteVideoStats, stats?.toMap()) - } - - override fun onRemoteAudioStats(stats: RemoteAudioStats?) { - callback(RtcEngineEvents.RemoteAudioStats, stats?.toMap()) - } - - @Deprecated("", ReplaceWith("onAudioMixingStateChanged")) - override fun onAudioMixingFinished() { - callback(RtcEngineEvents.AudioMixingFinished) - } - - override fun onAudioMixingStateChanged(@Annotations.AgoraAudioMixingStateCode state: Int, @Annotations.AgoraAudioMixingErrorCode errorCode: Int) { - callback(RtcEngineEvents.AudioMixingStateChanged, state, errorCode) - } - - override fun onAudioEffectFinished(soundId: Int) { - callback(RtcEngineEvents.AudioEffectFinished, soundId) - } - - override fun onRtmpStreamingStateChanged(url: String?, @Annotations.AgoraRtmpStreamingState state: Int, @Annotations.AgoraRtmpStreamingErrorCode errCode: Int) { - callback(RtcEngineEvents.RtmpStreamingStateChanged, url, state, errCode) - } - - override fun onTranscodingUpdated() { - callback(RtcEngineEvents.TranscodingUpdated) - } - - override fun onStreamInjectedStatus(url: String?, uid: Int, @Annotations.AgoraInjectStreamStatus status: Int) { - callback(RtcEngineEvents.StreamInjectedStatus, url, uid, status) - } - - override fun onStreamMessage(uid: Int, streamId: Int, data: ByteArray?) { - callback(RtcEngineEvents.StreamMessage, uid, streamId, data?.let { String(it, Charsets.UTF_8) }) - } - - override fun onStreamMessageError(uid: Int, streamId: Int, @Annotations.AgoraErrorCode error: Int, missed: Int, cached: Int) { - callback(RtcEngineEvents.StreamMessageError, uid, streamId, error, missed, cached) - } - - override fun onMediaEngineLoadSuccess() { - callback(RtcEngineEvents.MediaEngineLoadSuccess) - } - - override fun onMediaEngineStartCallSuccess() { - callback(RtcEngineEvents.MediaEngineStartCallSuccess) - } - - override fun onChannelMediaRelayStateChanged(@Annotations.AgoraChannelMediaRelayState state: Int, @Annotations.AgoraChannelMediaRelayError code: Int) { - callback(RtcEngineEvents.ChannelMediaRelayStateChanged, state, code) - } - - override fun onChannelMediaRelayEvent(@Annotations.AgoraChannelMediaRelayEvent code: Int) { - callback(RtcEngineEvents.ChannelMediaRelayEvent, code) - } - - @Deprecated("", ReplaceWith("onRemoteVideoStateChanged")) - override fun onFirstRemoteVideoFrame(uid: Int, width: Int, height: Int, elapsed: Int) { - callback(RtcEngineEvents.FirstRemoteVideoFrame, uid, width, height, elapsed) - } - - @Deprecated("", ReplaceWith("onRemoteAudioStateChanged")) - override fun onFirstRemoteAudioFrame(uid: Int, elapsed: Int) { - callback(RtcEngineEvents.FirstRemoteAudioFrame, uid, elapsed) - } - - @Deprecated("", ReplaceWith("onRemoteAudioStateChanged")) - override fun onFirstRemoteAudioDecoded(uid: Int, elapsed: Int) { - callback(RtcEngineEvents.FirstRemoteAudioDecoded, uid, elapsed) - } - - @Deprecated("", ReplaceWith("onRemoteAudioStateChanged")) - override fun onUserMuteAudio(uid: Int, muted: Boolean) { - callback(RtcEngineEvents.UserMuteAudio, uid, muted) - } - - @Deprecated("", ReplaceWith("onRtmpStreamingStateChanged")) - override fun onStreamPublished(url: String?, @Annotations.AgoraErrorCode error: Int) { - callback(RtcEngineEvents.StreamPublished, url, error) - } - - @Deprecated("", ReplaceWith("onRtmpStreamingStateChanged")) - override fun onStreamUnpublished(url: String?) { - callback(RtcEngineEvents.StreamUnpublished, url) - } - - @Deprecated("", ReplaceWith("onRemoteAudioStats")) - override fun onRemoteAudioTransportStats(uid: Int, delay: Int, lost: Int, rxKBitRate: Int) { - callback(RtcEngineEvents.RemoteAudioTransportStats, uid, delay, lost, rxKBitRate) - } - - @Deprecated("", ReplaceWith("onRemoteVideoStats")) - override fun onRemoteVideoTransportStats(uid: Int, delay: Int, lost: Int, rxKBitRate: Int) { - callback(RtcEngineEvents.RemoteVideoTransportStats, uid, delay, lost, rxKBitRate) - } - - @Deprecated("", ReplaceWith("onRemoteVideoStateChanged")) - override fun onUserEnableVideo(uid: Int, enabled: Boolean) { - callback(RtcEngineEvents.UserEnableVideo, uid, enabled) - } - - @Deprecated("", ReplaceWith("onRemoteVideoStateChanged")) - override fun onUserEnableLocalVideo(uid: Int, enabled: Boolean) { - callback(RtcEngineEvents.UserEnableLocalVideo, uid, enabled) - } - - @Deprecated("", ReplaceWith("onRemoteVideoStateChanged")) - override fun onFirstRemoteVideoDecoded(uid: Int, width: Int, height: Int, elapsed: Int) { - callback(RtcEngineEvents.FirstRemoteVideoDecoded, uid, width, height, elapsed) - } - - @Deprecated("", ReplaceWith("onLocalAudioStateChanged")) - override fun onMicrophoneEnabled(enabled: Boolean) { - callback(RtcEngineEvents.MicrophoneEnabled, enabled) - } - - @Deprecated("", ReplaceWith("onConnectionStateChanged")) - override fun onConnectionInterrupted() { - callback(RtcEngineEvents.ConnectionInterrupted) - } - - @Deprecated("", ReplaceWith("onConnectionStateChanged")) - override fun onConnectionBanned() { - callback(RtcEngineEvents.ConnectionBanned) - } - - @Deprecated("", ReplaceWith("onRemoteAudioStats")) - override fun onAudioQuality(uid: Int, @Annotations.AgoraNetworkQuality quality: Int, delay: Short, lost: Short) { - callback(RtcEngineEvents.AudioQuality, uid, quality, delay, lost) - } - - @Deprecated("", ReplaceWith("onLocalVideoStateChanged")) - override fun onCameraReady() { - callback(RtcEngineEvents.CameraReady) - } - - @Deprecated("", ReplaceWith("onLocalVideoStateChanged")) - override fun onVideoStopped() { - callback(RtcEngineEvents.VideoStopped) - } - - override fun onFirstLocalAudioFramePublished(elapsed: Int) { - callback(RtcEngineEvents.FirstLocalAudioFramePublished, elapsed) - } - - override fun onFirstLocalVideoFramePublished(elapsed: Int) { - callback(RtcEngineEvents.FirstLocalVideoFramePublished, elapsed) - } - - override fun onAudioPublishStateChanged(channel: String?, @Annotations.AgoraStreamPublishState oldState: Int, @Annotations.AgoraStreamPublishState newState: Int, elapseSinceLastState: Int) { - callback(RtcEngineEvents.AudioPublishStateChanged, channel, oldState, newState, elapseSinceLastState) - } - - override fun onVideoPublishStateChanged(channel: String?, @Annotations.AgoraStreamPublishState oldState: Int, @Annotations.AgoraStreamPublishState newState: Int, elapseSinceLastState: Int) { - callback(RtcEngineEvents.VideoPublishStateChanged, channel, oldState, newState, elapseSinceLastState) - } - - override fun onAudioSubscribeStateChanged(channel: String?, uid: Int, @Annotations.AgoraStreamSubscribeState oldState: Int, @Annotations.AgoraStreamSubscribeState newState: Int, elapseSinceLastState: Int) { - callback(RtcEngineEvents.AudioSubscribeStateChanged, channel, uid, oldState, newState, elapseSinceLastState) - } - - override fun onVideoSubscribeStateChanged(channel: String?, uid: Int, @Annotations.AgoraStreamSubscribeState oldState: Int, @Annotations.AgoraStreamSubscribeState newState: Int, elapseSinceLastState: Int) { - callback(RtcEngineEvents.VideoSubscribeStateChanged, channel, uid, oldState, newState, elapseSinceLastState) - } - - override fun onRtmpStreamingEvent(url: String?, @Annotations.AgoraRtmpStreamingEvent error: Int) { - callback(RtcEngineEvents.RtmpStreamingEvent, url, error) - } + companion object { + const val PREFIX = "io.agora.rtc." + } + + private fun callback(methodName: String, vararg data: Any?) { + emitter(methodName, hashMapOf("data" to data.toList())) + } + + override fun onWarning(@Annotations.AgoraWarningCode warn: Int) { + callback(RtcEngineEvents.Warning, warn) + } + + override fun onError(@Annotations.AgoraErrorCode err: Int) { + callback(RtcEngineEvents.Error, err) + } + + override fun onApiCallExecuted(@Annotations.AgoraErrorCode error: Int, api: String?, result: String?) { + callback(RtcEngineEvents.ApiCallExecuted, error, api, result) + } + + override fun onJoinChannelSuccess(channel: String?, uid: Int, elapsed: Int) { + callback(RtcEngineEvents.JoinChannelSuccess, channel, uid, elapsed) + } + + override fun onRejoinChannelSuccess(channel: String?, uid: Int, elapsed: Int) { + callback(RtcEngineEvents.RejoinChannelSuccess, channel, uid, elapsed) + } + + override fun onLeaveChannel(stats: RtcStats?) { + callback(RtcEngineEvents.LeaveChannel, stats?.toMap()) + } + + override fun onLocalUserRegistered(uid: Int, userAccount: String?) { + callback(RtcEngineEvents.LocalUserRegistered, uid, userAccount) + } + + override fun onUserInfoUpdated(uid: Int, userInfo: UserInfo?) { + callback(RtcEngineEvents.UserInfoUpdated, uid, userInfo?.toMap()) + } + + override fun onClientRoleChanged(@Annotations.AgoraClientRole oldRole: Int, @Annotations.AgoraClientRole newRole: Int) { + callback(RtcEngineEvents.ClientRoleChanged, oldRole, newRole) + } + + override fun onUserJoined(uid: Int, elapsed: Int) { + callback(RtcEngineEvents.UserJoined, uid, elapsed) + } + + override fun onUserOffline(uid: Int, @Annotations.AgoraUserOfflineReason reason: Int) { + callback(RtcEngineEvents.UserOffline, uid, reason) + } + + override fun onConnectionStateChanged(@Annotations.AgoraConnectionStateType state: Int, @Annotations.AgoraConnectionChangedReason reason: Int) { + callback(RtcEngineEvents.ConnectionStateChanged, state, reason) + } + + override fun onNetworkTypeChanged(@Annotations.AgoraNetworkType type: Int) { + callback(RtcEngineEvents.NetworkTypeChanged, type) + } + + override fun onConnectionLost() { + callback(RtcEngineEvents.ConnectionLost) + } + + override fun onTokenPrivilegeWillExpire(token: String?) { + callback(RtcEngineEvents.TokenPrivilegeWillExpire, token) + } + + override fun onRequestToken() { + callback(RtcEngineEvents.RequestToken) + } + + override fun onAudioVolumeIndication(speakers: Array?, @IntRange(from = 0, to = 255) totalVolume: Int) { + callback(RtcEngineEvents.AudioVolumeIndication, speakers?.toMapList(), totalVolume) + } + + override fun onActiveSpeaker(uid: Int) { + callback(RtcEngineEvents.ActiveSpeaker, uid) + } + + override fun onFirstLocalAudioFrame(elapsed: Int) { + callback(RtcEngineEvents.FirstLocalAudioFrame, elapsed) + } + + override fun onFirstLocalVideoFrame(width: Int, height: Int, elapsed: Int) { + callback(RtcEngineEvents.FirstLocalVideoFrame, width, height, elapsed) + } + + @Deprecated("", ReplaceWith("onRemoteVideoStateChanged")) + override fun onUserMuteVideo(uid: Int, muted: Boolean) { + callback(RtcEngineEvents.UserMuteVideo, uid, muted) + } + + override fun onVideoSizeChanged(uid: Int, width: Int, height: Int, @IntRange(from = 0, to = 360) rotation: Int) { + callback(RtcEngineEvents.VideoSizeChanged, uid, width, height, rotation) + } + + override fun onRemoteVideoStateChanged(uid: Int, @Annotations.AgoraVideoRemoteState state: Int, @Annotations.AgoraVideoRemoteStateReason reason: Int, elapsed: Int) { + callback(RtcEngineEvents.RemoteVideoStateChanged, uid, state, reason, elapsed) + } + + override fun onLocalVideoStateChanged(@Annotations.AgoraLocalVideoStreamState localVideoState: Int, @Annotations.AgoraLocalVideoStreamError error: Int) { + callback(RtcEngineEvents.LocalVideoStateChanged, localVideoState, error) + } + + override fun onRemoteAudioStateChanged(uid: Int, @Annotations.AgoraAudioRemoteState state: Int, @Annotations.AgoraAudioRemoteStateReason reason: Int, elapsed: Int) { + callback(RtcEngineEvents.RemoteAudioStateChanged, uid, state, reason, elapsed) + } + + override fun onLocalAudioStateChanged(@Annotations.AgoraAudioLocalState state: Int, @Annotations.AgoraAudioLocalError error: Int) { + callback(RtcEngineEvents.LocalAudioStateChanged, state, error) + } + + override fun onLocalPublishFallbackToAudioOnly(isFallbackOrRecover: Boolean) { + callback(RtcEngineEvents.LocalPublishFallbackToAudioOnly, isFallbackOrRecover) + } + + override fun onRemoteSubscribeFallbackToAudioOnly(uid: Int, isFallbackOrRecover: Boolean) { + callback(RtcEngineEvents.RemoteSubscribeFallbackToAudioOnly, uid, isFallbackOrRecover) + } + + override fun onAudioRouteChanged(@Annotations.AgoraAudioOutputRouting routing: Int) { + callback(RtcEngineEvents.AudioRouteChanged, routing) + } + + override fun onCameraFocusAreaChanged(rect: Rect?) { + callback(RtcEngineEvents.CameraFocusAreaChanged, rect?.toMap()) + } + + override fun onCameraExposureAreaChanged(rect: Rect?) { + callback(RtcEngineEvents.CameraExposureAreaChanged, rect?.toMap()) + } + + override fun onFacePositionChanged(imageWidth: Int, imageHeight: Int, faces: Array?) { + callback(RtcEngineEvents.FacePositionChanged, imageWidth, imageHeight, faces?.toMapList()) + } + + override fun onRtcStats(stats: RtcStats?) { + callback(RtcEngineEvents.RtcStats, stats?.toMap()) + } + + override fun onLastmileQuality(@Annotations.AgoraNetworkQuality quality: Int) { + callback(RtcEngineEvents.LastmileQuality, quality) + } + + override fun onNetworkQuality(uid: Int, @Annotations.AgoraNetworkQuality txQuality: Int, @Annotations.AgoraNetworkQuality rxQuality: Int) { + callback(RtcEngineEvents.NetworkQuality, uid, txQuality, rxQuality) + } + + override fun onLastmileProbeResult(result: LastmileProbeResult?) { + callback(RtcEngineEvents.LastmileProbeResult, result?.toMap()) + } + + @Deprecated("", ReplaceWith("onLocalVideoStats")) + override fun onLocalVideoStat(sentBitrate: Int, sentFrameRate: Int) { + // TODO Not in iOS + } + + override fun onLocalVideoStats(stats: LocalVideoStats?) { + callback(RtcEngineEvents.LocalVideoStats, stats?.toMap()) + } + + override fun onLocalAudioStats(stats: LocalAudioStats?) { + callback(RtcEngineEvents.LocalAudioStats, stats?.toMap()) + } + + @Deprecated("", ReplaceWith("onRemoteVideoStats")) + override fun onRemoteVideoStat(uid: Int, delay: Int, receivedBitrate: Int, receivedFrameRate: Int) { + // TODO Not in iOS + } + + override fun onRemoteVideoStats(stats: RemoteVideoStats?) { + callback(RtcEngineEvents.RemoteVideoStats, stats?.toMap()) + } + + override fun onRemoteAudioStats(stats: RemoteAudioStats?) { + callback(RtcEngineEvents.RemoteAudioStats, stats?.toMap()) + } + + @Deprecated("", ReplaceWith("onAudioMixingStateChanged")) + override fun onAudioMixingFinished() { + callback(RtcEngineEvents.AudioMixingFinished) + } + + override fun onAudioMixingStateChanged(@Annotations.AgoraAudioMixingStateCode state: Int, @Annotations.AgoraAudioMixingErrorCode errorCode: Int) { + callback(RtcEngineEvents.AudioMixingStateChanged, state, errorCode) + } + + override fun onAudioEffectFinished(soundId: Int) { + callback(RtcEngineEvents.AudioEffectFinished, soundId) + } + + override fun onRtmpStreamingStateChanged(url: String?, @Annotations.AgoraRtmpStreamingState state: Int, @Annotations.AgoraRtmpStreamingErrorCode errCode: Int) { + callback(RtcEngineEvents.RtmpStreamingStateChanged, url, state, errCode) + } + + override fun onTranscodingUpdated() { + callback(RtcEngineEvents.TranscodingUpdated) + } + + override fun onStreamInjectedStatus(url: String?, uid: Int, @Annotations.AgoraInjectStreamStatus status: Int) { + callback(RtcEngineEvents.StreamInjectedStatus, url, uid, status) + } + + override fun onStreamMessage(uid: Int, streamId: Int, data: ByteArray?) { + callback(RtcEngineEvents.StreamMessage, uid, streamId, data?.let { String(it, Charsets.UTF_8) }) + } + + override fun onStreamMessageError(uid: Int, streamId: Int, @Annotations.AgoraErrorCode error: Int, missed: Int, cached: Int) { + callback(RtcEngineEvents.StreamMessageError, uid, streamId, error, missed, cached) + } + + override fun onMediaEngineLoadSuccess() { + callback(RtcEngineEvents.MediaEngineLoadSuccess) + } + + override fun onMediaEngineStartCallSuccess() { + callback(RtcEngineEvents.MediaEngineStartCallSuccess) + } + + override fun onChannelMediaRelayStateChanged(@Annotations.AgoraChannelMediaRelayState state: Int, @Annotations.AgoraChannelMediaRelayError code: Int) { + callback(RtcEngineEvents.ChannelMediaRelayStateChanged, state, code) + } + + override fun onChannelMediaRelayEvent(@Annotations.AgoraChannelMediaRelayEvent code: Int) { + callback(RtcEngineEvents.ChannelMediaRelayEvent, code) + } + + @Deprecated("", ReplaceWith("onRemoteVideoStateChanged")) + override fun onFirstRemoteVideoFrame(uid: Int, width: Int, height: Int, elapsed: Int) { + callback(RtcEngineEvents.FirstRemoteVideoFrame, uid, width, height, elapsed) + } + + @Deprecated("", ReplaceWith("onRemoteAudioStateChanged")) + override fun onFirstRemoteAudioFrame(uid: Int, elapsed: Int) { + callback(RtcEngineEvents.FirstRemoteAudioFrame, uid, elapsed) + } + + @Deprecated("", ReplaceWith("onRemoteAudioStateChanged")) + override fun onFirstRemoteAudioDecoded(uid: Int, elapsed: Int) { + callback(RtcEngineEvents.FirstRemoteAudioDecoded, uid, elapsed) + } + + @Deprecated("", ReplaceWith("onRemoteAudioStateChanged")) + override fun onUserMuteAudio(uid: Int, muted: Boolean) { + callback(RtcEngineEvents.UserMuteAudio, uid, muted) + } + + @Deprecated("", ReplaceWith("onRtmpStreamingStateChanged")) + override fun onStreamPublished(url: String?, @Annotations.AgoraErrorCode error: Int) { + callback(RtcEngineEvents.StreamPublished, url, error) + } + + @Deprecated("", ReplaceWith("onRtmpStreamingStateChanged")) + override fun onStreamUnpublished(url: String?) { + callback(RtcEngineEvents.StreamUnpublished, url) + } + + @Deprecated("", ReplaceWith("onRemoteAudioStats")) + override fun onRemoteAudioTransportStats(uid: Int, delay: Int, lost: Int, rxKBitRate: Int) { + callback(RtcEngineEvents.RemoteAudioTransportStats, uid, delay, lost, rxKBitRate) + } + + @Deprecated("", ReplaceWith("onRemoteVideoStats")) + override fun onRemoteVideoTransportStats(uid: Int, delay: Int, lost: Int, rxKBitRate: Int) { + callback(RtcEngineEvents.RemoteVideoTransportStats, uid, delay, lost, rxKBitRate) + } + + @Deprecated("", ReplaceWith("onRemoteVideoStateChanged")) + override fun onUserEnableVideo(uid: Int, enabled: Boolean) { + callback(RtcEngineEvents.UserEnableVideo, uid, enabled) + } + + @Deprecated("", ReplaceWith("onRemoteVideoStateChanged")) + override fun onUserEnableLocalVideo(uid: Int, enabled: Boolean) { + callback(RtcEngineEvents.UserEnableLocalVideo, uid, enabled) + } + + @Deprecated("", ReplaceWith("onRemoteVideoStateChanged")) + override fun onFirstRemoteVideoDecoded(uid: Int, width: Int, height: Int, elapsed: Int) { + callback(RtcEngineEvents.FirstRemoteVideoDecoded, uid, width, height, elapsed) + } + + @Deprecated("", ReplaceWith("onLocalAudioStateChanged")) + override fun onMicrophoneEnabled(enabled: Boolean) { + callback(RtcEngineEvents.MicrophoneEnabled, enabled) + } + + @Deprecated("", ReplaceWith("onConnectionStateChanged")) + override fun onConnectionInterrupted() { + callback(RtcEngineEvents.ConnectionInterrupted) + } + + @Deprecated("", ReplaceWith("onConnectionStateChanged")) + override fun onConnectionBanned() { + callback(RtcEngineEvents.ConnectionBanned) + } + + @Deprecated("", ReplaceWith("onRemoteAudioStats")) + override fun onAudioQuality(uid: Int, @Annotations.AgoraNetworkQuality quality: Int, delay: Short, lost: Short) { + callback(RtcEngineEvents.AudioQuality, uid, quality, delay, lost) + } + + @Deprecated("", ReplaceWith("onLocalVideoStateChanged")) + override fun onCameraReady() { + callback(RtcEngineEvents.CameraReady) + } + + @Deprecated("", ReplaceWith("onLocalVideoStateChanged")) + override fun onVideoStopped() { + callback(RtcEngineEvents.VideoStopped) + } + + override fun onFirstLocalAudioFramePublished(elapsed: Int) { + callback(RtcEngineEvents.FirstLocalAudioFramePublished, elapsed) + } + + override fun onFirstLocalVideoFramePublished(elapsed: Int) { + callback(RtcEngineEvents.FirstLocalVideoFramePublished, elapsed) + } + + override fun onAudioPublishStateChanged(channel: String?, @Annotations.AgoraStreamPublishState oldState: Int, @Annotations.AgoraStreamPublishState newState: Int, elapseSinceLastState: Int) { + callback(RtcEngineEvents.AudioPublishStateChanged, channel, oldState, newState, elapseSinceLastState) + } + + override fun onVideoPublishStateChanged(channel: String?, @Annotations.AgoraStreamPublishState oldState: Int, @Annotations.AgoraStreamPublishState newState: Int, elapseSinceLastState: Int) { + callback(RtcEngineEvents.VideoPublishStateChanged, channel, oldState, newState, elapseSinceLastState) + } + + override fun onAudioSubscribeStateChanged(channel: String?, uid: Int, @Annotations.AgoraStreamSubscribeState oldState: Int, @Annotations.AgoraStreamSubscribeState newState: Int, elapseSinceLastState: Int) { + callback(RtcEngineEvents.AudioSubscribeStateChanged, channel, uid, oldState, newState, elapseSinceLastState) + } + + override fun onVideoSubscribeStateChanged(channel: String?, uid: Int, @Annotations.AgoraStreamSubscribeState oldState: Int, @Annotations.AgoraStreamSubscribeState newState: Int, elapseSinceLastState: Int) { + callback(RtcEngineEvents.VideoSubscribeStateChanged, channel, uid, oldState, newState, elapseSinceLastState) + } + + override fun onRtmpStreamingEvent(url: String?, @Annotations.AgoraRtmpStreamingEvent error: Int) { + callback(RtcEngineEvents.RtmpStreamingEvent, url, error) + } } diff --git a/RtcSurfaceView.kt b/RtcSurfaceView.kt index f47b7fc0f..285478162 100644 --- a/RtcSurfaceView.kt +++ b/RtcSurfaceView.kt @@ -9,92 +9,92 @@ import io.agora.rtc.video.VideoCanvas import java.lang.ref.WeakReference class RtcSurfaceView( - context: Context + context: Context ) : FrameLayout(context) { - private var surface: SurfaceView - private var canvas: VideoCanvas - private var channel: WeakReference? = null + private var surface: SurfaceView + private var canvas: VideoCanvas + private var channel: WeakReference? = null - init { - try { - surface = RtcEngine.CreateRendererView(context) - } catch (e: UnsatisfiedLinkError) { - throw RuntimeException("Please init RtcEngine first!") - } - canvas = VideoCanvas(surface) - addView(surface) + init { + try { + surface = RtcEngine.CreateRendererView(context) + } catch (e: UnsatisfiedLinkError) { + throw RuntimeException("Please init RtcEngine first!") } + canvas = VideoCanvas(surface) + addView(surface) + } - fun setZOrderMediaOverlay(isMediaOverlay: Boolean) { - try { - removeView(surface) - surface.setZOrderMediaOverlay(isMediaOverlay) - addView(surface) - } catch (e: Exception) { - e.printStackTrace() - } + fun setZOrderMediaOverlay(isMediaOverlay: Boolean) { + try { + removeView(surface) + surface.setZOrderMediaOverlay(isMediaOverlay) + addView(surface) + } catch (e: Exception) { + e.printStackTrace() } + } - fun setZOrderOnTop(onTop: Boolean) { - try { - removeView(surface) - surface.setZOrderOnTop(onTop) - addView(surface) - } catch (e: Exception) { - e.printStackTrace() - } + fun setZOrderOnTop(onTop: Boolean) { + try { + removeView(surface) + surface.setZOrderOnTop(onTop) + addView(surface) + } catch (e: Exception) { + e.printStackTrace() } + } - fun setData(engine: RtcEngine, channel: RtcChannel?, uid: Int) { - this.channel = if (channel != null) WeakReference(channel) else null - canvas.channelId = this.channel?.get()?.channelId() - canvas.uid = uid - setupVideoCanvas(engine) - } + fun setData(engine: RtcEngine, channel: RtcChannel?, uid: Int) { + this.channel = if (channel != null) WeakReference(channel) else null + canvas.channelId = this.channel?.get()?.channelId() + canvas.uid = uid + setupVideoCanvas(engine) + } - fun resetVideoCanvas(engine: RtcEngine) { - val canvas = VideoCanvas(null, canvas.renderMode, canvas.channelId, canvas.uid, canvas.mirrorMode) - if (canvas.uid == 0) { - engine.setupLocalVideo(canvas) - } else { - engine.setupRemoteVideo(canvas) - } + fun resetVideoCanvas(engine: RtcEngine) { + val canvas = VideoCanvas(null, canvas.renderMode, canvas.channelId, canvas.uid, canvas.mirrorMode) + if (canvas.uid == 0) { + engine.setupLocalVideo(canvas) + } else { + engine.setupRemoteVideo(canvas) } + } - private fun setupVideoCanvas(engine: RtcEngine) { - if (canvas.uid == 0) { - engine.setupLocalVideo(canvas) - } else { - engine.setupRemoteVideo(canvas) - } + private fun setupVideoCanvas(engine: RtcEngine) { + if (canvas.uid == 0) { + engine.setupLocalVideo(canvas) + } else { + engine.setupRemoteVideo(canvas) } + } - fun setRenderMode(engine: RtcEngine, @Annotations.AgoraVideoRenderMode renderMode: Int) { - canvas.renderMode = renderMode - setupRenderMode(engine) - } + fun setRenderMode(engine: RtcEngine, @Annotations.AgoraVideoRenderMode renderMode: Int) { + canvas.renderMode = renderMode + setupRenderMode(engine) + } - fun setMirrorMode(engine: RtcEngine, @Annotations.AgoraVideoMirrorMode mirrorMode: Int) { - canvas.mirrorMode = mirrorMode - setupRenderMode(engine) - } + fun setMirrorMode(engine: RtcEngine, @Annotations.AgoraVideoMirrorMode mirrorMode: Int) { + canvas.mirrorMode = mirrorMode + setupRenderMode(engine) + } - private fun setupRenderMode(engine: RtcEngine) { - if (canvas.uid == 0) { - engine.setLocalRenderMode(canvas.renderMode, canvas.mirrorMode) - } else { - channel?.get()?.let { - it.setRemoteRenderMode(canvas.uid, canvas.renderMode, canvas.mirrorMode) - return@setupRenderMode - } - engine.setRemoteRenderMode(canvas.uid, canvas.renderMode, canvas.mirrorMode) - } + private fun setupRenderMode(engine: RtcEngine) { + if (canvas.uid == 0) { + engine.setLocalRenderMode(canvas.renderMode, canvas.mirrorMode) + } else { + channel?.get()?.let { + it.setRemoteRenderMode(canvas.uid, canvas.renderMode, canvas.mirrorMode) + return@setupRenderMode + } + engine.setRemoteRenderMode(canvas.uid, canvas.renderMode, canvas.mirrorMode) } + } - override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) { - val width: Int = MeasureSpec.getSize(widthMeasureSpec) - val height: Int = MeasureSpec.getSize(heightMeasureSpec) - surface.layout(0, 0, width, height) - super.onMeasure(widthMeasureSpec, heightMeasureSpec) - } + override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) { + val width: Int = MeasureSpec.getSize(widthMeasureSpec) + val height: Int = MeasureSpec.getSize(heightMeasureSpec) + surface.layout(0, 0, width, height) + super.onMeasure(widthMeasureSpec, heightMeasureSpec) + } } diff --git a/RtcTextureView.kt b/RtcTextureView.kt index 1a64d6fa8..4927e85e0 100644 --- a/RtcTextureView.kt +++ b/RtcTextureView.kt @@ -9,72 +9,72 @@ import io.agora.rtc.video.VideoCanvas import java.lang.ref.WeakReference class RtcTextureView( - context: Context + context: Context ) : FrameLayout(context) { - private var texture: TextureView - private var canvas: VideoCanvas - private var channel: WeakReference? = null + private var texture: TextureView + private var canvas: VideoCanvas + private var channel: WeakReference? = null - init { - try { - texture = RtcEngine.CreateTextureView(context) - } catch (e: UnsatisfiedLinkError) { - throw RuntimeException("Please init RtcEngine first!") - } - canvas = VideoCanvas(texture) - addView(texture) + init { + try { + texture = RtcEngine.CreateTextureView(context) + } catch (e: UnsatisfiedLinkError) { + throw RuntimeException("Please init RtcEngine first!") } + canvas = VideoCanvas(texture) + addView(texture) + } - fun setData(engine: RtcEngine, channel: RtcChannel?, uid: Int) { - this.channel = if (channel != null) WeakReference(channel) else null - canvas.channelId = this.channel?.get()?.channelId() - canvas.uid = uid - setupVideoCanvas(engine) - } + fun setData(engine: RtcEngine, channel: RtcChannel?, uid: Int) { + this.channel = if (channel != null) WeakReference(channel) else null + canvas.channelId = this.channel?.get()?.channelId() + canvas.uid = uid + setupVideoCanvas(engine) + } - fun resetVideoCanvas(engine: RtcEngine) { - val canvas = VideoCanvas(null, canvas.renderMode, canvas.channelId, canvas.uid, canvas.mirrorMode) - if (canvas.uid == 0) { - engine.setupLocalVideo(canvas) - } else { - engine.setupRemoteVideo(canvas) - } + fun resetVideoCanvas(engine: RtcEngine) { + val canvas = VideoCanvas(null, canvas.renderMode, canvas.channelId, canvas.uid, canvas.mirrorMode) + if (canvas.uid == 0) { + engine.setupLocalVideo(canvas) + } else { + engine.setupRemoteVideo(canvas) } + } - private fun setupVideoCanvas(engine: RtcEngine) { - if (canvas.uid == 0) { - engine.setupLocalVideo(canvas) - } else { - engine.setupRemoteVideo(canvas) - } + private fun setupVideoCanvas(engine: RtcEngine) { + if (canvas.uid == 0) { + engine.setupLocalVideo(canvas) + } else { + engine.setupRemoteVideo(canvas) } + } - fun setRenderMode(engine: RtcEngine, @Annotations.AgoraVideoRenderMode renderMode: Int) { - canvas.renderMode = renderMode - setupRenderMode(engine) - } + fun setRenderMode(engine: RtcEngine, @Annotations.AgoraVideoRenderMode renderMode: Int) { + canvas.renderMode = renderMode + setupRenderMode(engine) + } - fun setMirrorMode(engine: RtcEngine, @Annotations.AgoraVideoMirrorMode mirrorMode: Int) { - canvas.mirrorMode = mirrorMode - setupRenderMode(engine) - } + fun setMirrorMode(engine: RtcEngine, @Annotations.AgoraVideoMirrorMode mirrorMode: Int) { + canvas.mirrorMode = mirrorMode + setupRenderMode(engine) + } - private fun setupRenderMode(engine: RtcEngine) { - if (canvas.uid == 0) { - engine.setLocalRenderMode(canvas.renderMode, canvas.mirrorMode) - } else { - channel?.get()?.let { - it.setRemoteRenderMode(canvas.uid, canvas.renderMode, canvas.mirrorMode) - return@setupRenderMode - } - engine.setRemoteRenderMode(canvas.uid, canvas.renderMode, canvas.mirrorMode) - } + private fun setupRenderMode(engine: RtcEngine) { + if (canvas.uid == 0) { + engine.setLocalRenderMode(canvas.renderMode, canvas.mirrorMode) + } else { + channel?.get()?.let { + it.setRemoteRenderMode(canvas.uid, canvas.renderMode, canvas.mirrorMode) + return@setupRenderMode + } + engine.setRemoteRenderMode(canvas.uid, canvas.renderMode, canvas.mirrorMode) } + } - override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) { - val width: Int = MeasureSpec.getSize(widthMeasureSpec) - val height: Int = MeasureSpec.getSize(heightMeasureSpec) - texture.layout(0, 0, width, height) - super.onMeasure(widthMeasureSpec, heightMeasureSpec) - } + override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) { + val width: Int = MeasureSpec.getSize(widthMeasureSpec) + val height: Int = MeasureSpec.getSize(heightMeasureSpec) + texture.layout(0, 0, width, height) + super.onMeasure(widthMeasureSpec, heightMeasureSpec) + } }