# 声网3.4.1与阿里2.1接口对比

# Android端

  • 此文档中声网接口与回调总数为:227个。阿里对齐149个,未对齐78个,对齐比例为:65.6%

# 核心方法

声网接口 阿里接口 描述 对齐
create[1/2] (opens new window) getInstance[1/2] (opens new window) 创建 RtcEngine 实例 (opens new window)
create[2/2] (opens new window) getInstance[2/2] (opens new window) 创建 RtcEngine 实例(指定访问区域) (opens new window)
destroy (opens new window) destroy (opens new window) 销毁 RtcEngine 实例 (opens new window)
setChannelProfile (opens new window) setChannelProfile (opens new window) 设置频道场景
setClientRole[1/2] (opens new window) setClientRole (opens new window) 设置直播场景下的用户角色
setClientRole[2/2] (opens new window) 设置直播场景下的用户角色和用户级别
joinChannel[1/2] (opens new window) joinChannel (opens new window) 加入频道
joinChannel[2/2] (opens new window) 加入频道并设置订阅状态
switchChannel[1/2] (opens new window) switchChannel (opens new window) 快速切换直播频道
switchChannel[2/2] (opens new window) 快速切换直播频道并设置订阅状态
leaveChannel (opens new window) leaveChannel (opens new window) 离开频道
renewToken (opens new window) 更新 Token
getConnectionState (opens new window) getCurrentConnectionStatus (opens new window) 获取网络连接状态

# 核心事件

声网回调 阿里回调 描述 对齐
onConnectionStateChanged (opens new window) onConnectionStatusChange (opens new window) 网络连接状态已改变回调
onJoinChannelSuccess (opens new window) onJoinChannelResult (opens new window) 加入频道回调
onRejoinChannelSuccess (opens new window) onJoinChannelResult (opens new window) 重新加入频道回调
onLeaveChannel (opens new window) onLeaveChannelResult (opens new window) 离开频道回调
onClientRoleChanged (opens new window) onUpdateRoleNotify (opens new window) 用户角色已切换回调
onUserJoined (opens new window) onRemoteUserOnLineNotify (opens new window) 远端用户加入当前频道回调
onUserOffline (opens new window) onRemoteUserOffLineNotify (opens new window) 远端用户离开当前频道回调
onNetworkTypeChanged (opens new window) 本地网络类型发生改变回调
onConnectionLost (opens new window) onConnectionLost (opens new window) 网络连接丢失回调
onTokenPrivilegeWillExpire (opens new window) Token 服务即将过期回调
onRequestToken (opens new window) Token 已过期回调

# 音频管理

声网接口 阿里接口 描述 对齐
enableAudio (opens new window) 启用音频模块
disableAudio (opens new window) 关闭音频模块
setAudioProfile (opens new window) setAudioProfile (opens new window) 设置音频编码配置
adjustRecordingSignalVolume (opens new window) setRecordingVolume (opens new window) 调节采集信号音量
adjustUserPlaybackSignalVolume (opens new window) setRemoteAudioVolume (opens new window) 调节本地播放的指定远端用户信号音量
adjustPlaybackSignalVolume (opens new window) setPlayoutVolume (opens new window) 调节本地播放的所有远端用户信号音量
enableLocalAudio (opens new window) 开关本地音频采集
muteLocalAudioStream (opens new window) publishLocalAudioStream (opens new window) 停止/恢复发送本地音频流
muteRemoteAudioStream (opens new window) subscribeRemoteAudioStream (opens new window) 停止/恢复接收指定音频流
muteAllRemoteAudioStreams (opens new window) subscribeAllRemoteAudioStreams (opens new window) 停止/恢复接收所有音频流
setDefaultMuteAllRemoteAudioStreams (opens new window) setDefaultSubscribeAllRemoteAudioStreams (opens new window) 设置是否默认接收音频流

# 视频管理

声网接口 阿里接口 描述 对齐
enableVideo (opens new window) 启用视频模块
disableVideo (opens new window) 关闭视频模块
setVideoEncoderConfiguration (opens new window) setVideoEncoderConfiguration (opens new window) 设置视频编码配置
setupLocalVideo (opens new window) setLocalViewConfig (opens new window) 初始化本地视图
setupRemoteVideo (opens new window) setRemoteViewConfig (opens new window) 初始化远端用户视图
setLocalRenderMode[1/2] (opens new window) 更新本地视图显示模式
setRemoteRenderMode (opens new window) 更新远端视图显示模式
CreateRendererView (opens new window) createRenderSurfaceView (opens new window) 创建渲染视图
CreateTextureView (opens new window) createRenderTextureView (opens new window) 创建 TextureView
startPreview (opens new window) startPreview (opens new window) 开启视频预览
stopPreview (opens new window) stopPreview (opens new window) 停止视频预览
enableLocalVideo (opens new window) enableLocalVideo (opens new window) 开关本地视频采集
muteLocalVideoStream (opens new window) publishLocalVideoStream (opens new window) 停止/恢复发送本地视频流
muteRemoteVideoStream (opens new window) subscribeRemoteVideoStream (opens new window) 停止/恢复接收指定视频流
muteAllRemoteVideoStreams (opens new window) subscribeAllRemoteVideoStreams (opens new window) 停止/恢复接收所有视频流
setDefaultMuteAllRemoteVideoStreams (opens new window) setDefaultSubscribeAllRemoteVideoStreams (opens new window) 设置是否默认接收视频流

# 本地媒体事件

声网回调 阿里回调 描述 对齐
onLocalAudioStateChanged (opens new window) 本地音频状态改变回调
onLocalVideoStateChanged (opens new window) 本地视频状态改变回调
onFirstLocalAudioFramePublished (opens new window) onFirstRemoteAudioDecoded (opens new window) 已发布本地音频首帧回调
onFirstLocalVideoFramePublished (opens new window) 已发布本地视频首帧回调
onFirstLocalVideoFrame (opens new window) onFirstLocalVideoFrameDrawn (opens new window) 已显示本地视频首帧回调
onAudioPublishStateChanged (opens new window) onAudioPublishStateChanged (opens new window) 音频发布状态改变回调
onVideoPublishStateChanged (opens new window) onVideoPublishStateChanged (opens new window) 视频发布状态改变回调

# 远端媒体事件

声网回调 阿里回调 描述 对齐
onRemoteAudioStateChanged (opens new window) 远端用户音频状态已改变回调
onRemoteVideoStateChanged (opens new window) 远端用户视频状态已变化回调
onFirstRemoteVideoFrame (opens new window) onFirstRemoteVideoFrameDrawn (opens new window) 已显示远端视频首帧回调
onAudioSubscribeStateChanged (opens new window) onAudioSubscribeStateChanged (opens new window) 音频订阅状态改变回调
onVideoSubscribeStateChanged (opens new window) onVideoSubscribeStateChanged (opens new window) 视频订阅状态改变回调

数据统计事件

声网回调 阿里回调 描述 对齐
onRtcStats (opens new window) onAliRtcStats (opens new window) 当前通话统计回调
onNetworkQuality (opens new window) onNetworkQualityChanged (opens new window) 网络上下行质量报告回调
onLocalAudioStats (opens new window) onRtcLocalAudioStats (opens new window) 通话中本地音频流统计信息回调
onLocalVideoStats (opens new window) onRtcLocalVideoStats (opens new window) 通话中本地视频流统计信息回调
onRemoteAudioStats (opens new window) onRtcRemoteAudioStats (opens new window) 通话中远端音频流的统计信息回调
onRemoteVideoStats (opens new window) onRtcRemoteVideoStats (opens new window) 通话中远端视频流统计信息回调

# 视频前处理及后处理

声网接口 阿里接口 描述 对齐
setBeautyEffectOptions (opens new window) setBeautyEffect (opens new window) 设置美颜效果选项

多频道管理

声网接口 阿里接口 描述 对齐
createRtcChannel (opens new window) createChannel (opens new window) 创建并获取一个 RtcChannel 对象。通过创建多个对象,用户可以同时加入多个频道。 (opens new window)
RtcChannel (opens new window) AliRtcEngine 提供在指定频道内实现实时音视频功能的方法。
IRtcChannelEventHandler (opens new window) AliRtcEngineEventListener + AliRtcEngineNotify (opens new window) 提供监听指定频道事件和数据的回调。

# 音乐文件播放及混音

声网接口 阿里接口 描述 对齐
startAudioMixing (opens new window) startAudioAccompany (opens new window) 开始播放音乐文件
stopAudioMixing (opens new window) stopAudioAccompany (opens new window) 停止播放音乐文件
pauseAudioMixing (opens new window) pauseAudioAccompany (opens new window) 暂停播放音乐文件
resumeAudioMixing (opens new window) resumeAudioAccompany (opens new window) 恢复播放音乐文件
adjustAudioMixingVolume (opens new window) setAudioAccompanyVolume (opens new window) 调节音乐文件播放音量
adjustAudioMixingPlayoutVolume (opens new window) setAudioAccompanyPlayoutVolume (opens new window) 调节音乐文件的本地播放音量
adjustAudioMixingPublishVolume (opens new window) setAudioAccompanyPublishVolume (opens new window) 调节音乐文件的远端播放音量
setAudioMixingPitch (opens new window) 调整本地播放的音乐文件的音调
getAudioMixingPlayoutVolume (opens new window) getAudioAccompanyPlayoutVolume (opens new window) 获取音乐文件的本地播放音量
getAudioMixingPublishVolume (opens new window) getAudioAccompanyPublishVolume (opens new window) 获取音乐文件的远端播放音量
getAudioMixingDuration (opens new window) getAudioAccompanyDuration (opens new window) 获取音乐文件播放时长
getAudioMixingCurrentPosition (opens new window) getAudioAccompanyCurrentPosition (opens new window) 获取音乐文件的播放进度
setAudioMixingPosition (opens new window) setAudioAccompanyPosition (opens new window) 设置音乐文件的播放位置
onAudioMixingStateChanged (opens new window) onAudioPlayingStateChanged (opens new window) 本地用户的音乐文件播放状态已改变回调

# 音效文件播放管理

声网接口 阿里接口 描述 对齐
getAudioEffectManager (opens new window) 获取 IAudioEffectManager 类,以管理音效文件 (opens new window)
getEffectsVolume (opens new window) getAudioEffectPlayoutVolume (opens new window) 获取播放音效文件音量
setEffectsVolume (opens new window) setAudioEffectPlayoutVolume (opens new window) 设置播放音效文件音量
setVolumeOfEffect (opens new window) setAudioEffectPublishVolume (opens new window) 实时调整播放音效文件音量
playEffect (opens new window) playAudioEffect (opens new window) 播放指定音效文件
stopEffect (opens new window) stopAudioEffect (opens new window) 停止播放指定音效文件
stopAllEffects (opens new window) stopAllAudioEffects (opens new window) 停止播放所有音效文件
preloadEffect (opens new window) preloadAudioEffect (opens new window) 将音效文件加载至内存
unloadEffect (opens new window) unloadAudioEffect (opens new window) 从内存释放某个预加载的音效文件
pauseEffect (opens new window) pauseAudioEffect (opens new window) 暂停音效文件播放
pauseAllEffects (opens new window) pauseAllAudioEffects (opens new window) 暂停所有音效文件播放
resumeEffect (opens new window) resumeAudioEffect (opens new window) 恢复播放指定音效文件
resumeAllEffects (opens new window) resumeAllAudioEffects (opens new window) 恢复播放所有音效文件
事件 描述
onAudioEffectFinished (opens new window) onAudioEffectFinished 本地音效文件播放已结束回调

# 人声效果

声网接口 阿里接口 描述 对齐
setAudioEffectPreset (opens new window) 设置 SDK 预设的人声音效
setVoiceBeautifierPreset (opens new window) 设置 SDK 预设的美声效果
setVoiceBeautifierParameters (opens new window) 设置 SDK 预设美声效果的参数
setAudioEffectParameters (opens new window) 设置 SDK 预设人声音效的参数
setLocalVoicePitch (opens new window) setAudioEffectPitchValue (opens new window) 设置本地语音音调
setLocalVoiceEqualization (opens new window) 设置本地语音音效均衡
setLocalVoiceReverb (opens new window) setAudioEffectReverbParamType (opens new window) 设置本地音效混响
setVoiceConversionPreset (opens new window) setAudioEffectVoiceChangerMode (opens new window) 设置 SDK 预设的变声效果

# 听声辨位

声网接口 阿里接口 描述 对齐
enableSoundPositionIndication (opens new window) 开启/关闭远端用户的语音立体声
setRemoteVoicePosition (opens new window) 设置远端用户的语音位置

# CDN 推流

声网接口 阿里接口 描述 对齐
setLiveTranscoding (opens new window) startPublishLiveStream (opens new window) 设置直播转码
addPublishStreamUrl (opens new window) startPublishLiveStream (opens new window) 增加旁路推流地址
removePublishStreamUrl (opens new window) stopPublishLiveStream (opens new window) 删除旁路推流地址
事件 描述
onRtmpStreamingStateChanged (opens new window) onPublishLiveStreamStateChanged (opens new window) 旁路推流状态改变回调
onRtmpStreamingEvent (opens new window) onPublishLiveStreamStateChanged (opens new window) RTMP/RTMPS 推流事件回调
onTranscodingUpdated (opens new window) onPublishTaskStateChanged (opens new window) 旁路推流设置已被更新回调

# 跨频道媒体流转发

声网接口 阿里接口 描述 对齐
startChannelMediaRelay (opens new window) startChannelRelay (opens new window) 开始跨频道媒体流转发
updateChannelMediaRelay (opens new window) updateChannelRelay (opens new window) 更新媒体流转发的频道
stopChannelMediaRelay (opens new window) stopChannelRelay (opens new window) 停止跨频道媒体流转发
事件 描述
onChannelMediaRelayStateChanged (opens new window) onChannelRelayStateChanged (opens new window) 跨频道媒体流转发状态发生改变回调
onChannelMediaRelayEvent (opens new window) onChannelRelayEvent (opens new window) 跨频道媒体流转发事件回调

# 音量提示

声网接口 阿里接口 描述 对齐
enableAudioVolumeIndication (opens new window) enableAudioVolumeIndication (opens new window) 启用说话者音量提示
事件 描述
onAudioVolumeIndication (opens new window) onAudioVolume (opens new window) 提示频道内谁正在说话及说话者音量的回调
onActiveSpeaker (opens new window) onActiveSpeaker (opens new window) 监测到最活跃用户回调

# 人脸检测

声网接口 阿里接口 描述 对齐
enableFaceDetection (opens new window) 开启/关闭本地人脸检测
事件 描述
onFacePositionChanged (opens new window) 报告本地人脸检测结果

# 语音播放路由

声网接口 阿里接口 描述 对齐
setDefaultAudioRoutetoSpeakerphone (opens new window) 设置默认的音频播放路由
setEnableSpeakerphone (opens new window) enableSpeakerphone (opens new window) 启用/关闭扬声器播放
isSpeakerphoneEnabled (opens new window) isSpeakerOn (opens new window) 查询扬声器启用状态
事件 描述
onAudioRouteChanged (opens new window) onAudioRouteChanged (opens new window) 语音路由已改变回调

# 耳返控制

声网接口 阿里接口 描述 对齐
enableInEarMonitoring (opens new window) enableEarBack (opens new window) 开启耳返功能
setInEarMonitoringVolume (opens new window) setEarBackVolume (opens new window) 设置耳返音量

# 视频双流模式

声网接口 阿里接口 描述 对齐
enableDualStreamMode (opens new window) publishLocalDualStream (opens new window) 开关视频双流模式
setRemoteVideoStreamType (opens new window) setRemoteVideoStreamType (opens new window) 设置订阅的视频流类型
setRemoteDefaultVideoStreamType (opens new window) setRemoteDefaultVideoStreamType (opens new window) 设置默认订阅的视频流类型

# 音视频回退

声网接口 阿里接口 描述 对齐
setLocalPublishFallbackOption (opens new window) 设置弱网条件下发布的音视频流回退选项
setRemoteSubscribeFallbackOption (opens new window) 设置弱网条件下订阅的音视频流回退选项
setRemoteUserPriority (opens new window) 设置用户媒体流优先级
事件 描述
onLocalPublishFallbackToAudioOnly (opens new window) 本地发布流已回退为音频流或恢复为音视频流回调
onRemoteSubscribeFallbackToAudioOnly (opens new window) 远端订阅流已回退为音频流或恢复为音视频流回调

# 通话前网络测试

声网接口 阿里接口 描述 对齐
startEchoTest[1/2] (opens new window) 开始语音通话回路测试
stopEchoTest (opens new window) 停止语音通话回路测试
enableLastmileTest (opens new window) startNetworkQualityProbeTest (opens new window) 启用网络测试
disableLastmileTest (opens new window) stopNetworkQualityProbeTest (opens new window) 关闭网络测试
startLastmileProbeTest (opens new window) 开始通话前网络质量探测
stopLastmileProbeTest (opens new window) 停止通话前网络质量探测
事件 描述
onLastmileQuality (opens new window) onNetworkQualityProbeTest (opens new window) 本地网络质量报告回调
onLastmileProbeResult (opens new window) 本地网络上下行 Last-mile 质量报告回调

# 自定义视频模块

声网接口 阿里接口 描述 对齐
setVideoSource (opens new window) 设置自定义视频源
setLocalVideoRenderer (opens new window) 自定义本地视频渲染器
setRemoteVideoRenderer (opens new window) 自定义远端视频渲染器

# 视频自采集(仅适用于 Push 模式)

声网接口 阿里接口 描述 对齐
setExternalVideoSource (opens new window) setExternalVideoSource (opens new window) 配置外部视频源
pushExternalVideoFrame (opens new window) pushExternalVideoFrame (opens new window) 推送外部视频帧
isTextureEncodeSupported (opens new window) 检查视频是否支持 Texture 编码

# 音频自采集(仅适用于 Push 模式)

声网接口 阿里接口 描述 对齐
setExternalAudioSource (opens new window) setExternalAudioSource (opens new window) 设置外部音频采集参数
pushExternalAudioFrame (opens new window) pushExternalAudioFrameRawData (opens new window) 推送外部音频帧

# 音频自渲染

声网接口 阿里接口 描述 对齐
setExternalAudioSink (opens new window) setExternalAudioSource (opens new window) 设置外部音频渲染
pullPlaybackAudioFrame (opens new window) 拉取外部音频数据

# 原始音频数据

声网接口 阿里接口 描述 对齐
registerAudioFrameObserver (opens new window) registerAudioObserver (opens new window) 注册语音观测器对象
setRecordingAudioFrameParameters (opens new window) 设置采集的音频格式
setPlaybackAudioFrameParameters (opens new window) 设置播放的声音的格式
setMixedAudioFrameParameters (opens new window) 设置采集与播放声音混音后的数据格式
事件 描述
onRecordFrame (opens new window) onCaptureRawData (opens new window) 获得采集的原始音频
onPlaybackFrame (opens new window) 获得播放的原始音频
onPlaybackFrameBeforeMixing (opens new window) onCaptureRawData (opens new window) 获取单个远端用户混音前的音频数据
onMixedFrame (opens new window) onRenderData (opens new window) 获取本地用户和所有远端用户混音后的原始音频数据
isMultipleChannelFrameWanted (opens new window) 设置是否获取多个频道的原始音频数据
onPlaybackFrameBeforeMixingEx (opens new window) onPlaybackAudioFrameBeforeMixing (opens new window) 获取各频道单个远端用户混音前的音频播放数据

# 媒体附属信息

声网接口 阿里接口 描述 对齐
registerMediaMetadataObserver (opens new window) 注册媒体 Metadata 观测器
事件 描述
getMaxMetadataSize (opens new window) 请求 Metadata 的最大数据大小
onReadyToSendMetadata (opens new window) 发送端已准备好发送 Metadata
onMetadataReceived (opens new window) 接收端已收到 Metadata

# 直播水印

声网接口 阿里接口 描述 对齐
addVideoWatermark[1/2] (opens new window) addVideoWatermark (opens new window) 添加本地视频水印
clearVideoWatermarks (opens new window) clearVideoWatermark (opens new window) 删除已添加的视频水印

# 加密

声网接口 阿里接口 描述 对齐
enableEncryption (opens new window) 开启/关闭内置加密

# 音频录制

声网接口 阿里接口 描述 对齐
startAudioRecording[1/3] (opens new window) startRecord (opens new window) 开始客户端录音
stopAudioRecording (opens new window) stopRecord (opens new window) 停止客户端录音

# 摄像头控制

声网接口 阿里接口 描述 对齐
switchCamera (opens new window) switchCamera (opens new window) 切换前置/后置摄像头
isCameraZoomSupported (opens new window) 检测设备是否支持摄像头缩放功能
isCameraTorchSupported (opens new window) 检测设备是否支持闪光灯常开
isCameraFocusSupported (opens new window) isCameraSupportFocusPoint (opens new window) 检测设备是否支持手动对焦功能
isCameraExposurePositionSupported (opens new window) isCameraSupportExposurePoint (opens new window) 检测设备是否支持手动曝光功能
isCameraAutoFocusFaceModeSupported (opens new window) isCameraAutoFocusFaceModeSupported (opens new window) 检测设备是否支持人脸对焦功能
setCameraZoomFactor (opens new window) setCameraZoom (opens new window) 设置摄像头缩放比例
getCameraMaxZoomFactor (opens new window) 获取摄像头支持最大缩放比例
setCameraFocusPositionInPreview (opens new window) setCameraFocusPoint (opens new window) 设置手动对焦位置,并触发对焦
setCameraExposurePosition (opens new window) setCameraExposurePoint (opens new window) 设置手动曝光位置
setCameraTorchOn (opens new window) setCameraFlash (opens new window) 设置是否打开闪光灯
setCameraAutoFocusFaceModeEnabled (opens new window) setCameraAutoFocusFaceModeEnabled (opens new window) 设置是否开启人脸对焦功能
事件 描述
onCameraFocusAreaChanged (opens new window) 摄像头对焦区域已改变回调
onCameraExposureAreaChanged (opens new window) 摄像头曝光区域已改变回调

# 流消息

声网接口 阿里接口 描述 对齐
createDataStream[1/2] (opens new window) 创建数据流
sendStreamMessage (opens new window) 发送数据流
事件 描述
onStreamMessage (opens new window) 接收到对方数据流消息的回调
onStreamMessageError (opens new window) 接收对方数据流消息发生错误的回调

# 其他视频控制

声网接口 阿里接口 描述 对齐
setLocalVideoMirrorMode (opens new window) 设置本地视频镜像模式
setCameraCapturerConfiguration (opens new window) setCameraCapturerConfiguration (opens new window) 设置摄像头的采集配置

# 其他方法

声网接口 阿里接口 描述 对齐
sendCustomReportMessage (opens new window) 自定义数据上报
getCallId (opens new window) 获取通话 ID
rate (opens new window) 给通话评分
complain (opens new window) 投诉通话质量
getSdkVersion (opens new window) getSDKVersion (opens new window) 查询 SDK 版本号
getErrorDescription (opens new window) getErrorDescription (opens new window) 获取警告或错误描述
getNativeHandle (opens new window) 获取 SDK 引擎的 Native 句柄
addHandler (opens new window) setRtcEngineNotify (opens new window)setRtcEngineEventListener (opens new window) 添加 IRtcEngineEventHandler 主回调事件 (opens new window)
removeHandler (opens new window) setRtcEngineNotify (opens new window)setRtcEngineEventListener (opens new window) 删除指定的 IRtcEngineEventHandler 回调句柄 (opens new window)
enableDeepLearningDenoise (opens new window) startIntelligentDenoise (opens new window)stopIntelligentDenoise (opens new window) 开启或关闭 AI 降噪模式
setCloudProxy (opens new window) 设置 Agora 云代理服务
其他事件
事件 描述
onWarning (opens new window) onOccurWarning (opens new window) 发生警告回调
onError (opens new window) onOccurError (opens new window) 发生错误回调
onApiCallExecuted (opens new window) API 方法已执行回调