类 | |
class | AreaCode |
class | AudioCodecOption |
class | AudioCodecType |
class | AudioDataType |
class | AudioFrameInfo |
class | ChannelOptions |
class | CloudProxyType |
class | ConnectionIdSpecial |
class | ConnectionInfo |
class | ErrorCode |
class | LicenseValidationErrorReason |
class | LogConfig |
class | LogLevel |
class | NetworkEventType |
class | RtcAudioProcessOption |
class | RtcServiceOptions |
class | RtmErrCode |
class | UserOfflineReason |
class | VideoDataType |
class | VideoFrameInfo |
class | VideoFrameRate |
class | VideoFrameType |
class | VideoStreamType |
Public 成员函数 | |
native String | getVersion () |
native String | errToStr (int err) |
native String | licenseGenCredential () |
native int | licenseVerify (String certificate, String credential) |
native int | init (String appId, AgoraRtcEvents events, RtcServiceOptions options) |
native int | fini () |
native int | setLogLevel (int level) |
native int | configLog (int sizePerFile, int maxFileCount) |
native int | notifyNetworkEvent (int event) |
native int | createConnection () |
native int | destroyConnection (int connId) |
native int | getConnectionInfo (int connId, ConnectionInfo connInfo) |
native int | joinChannel (int connId, String channelName, int uid, String token, ChannelOptions options) |
native int | leaveChannel (int connId) |
native int | renewToken (int connId, String token) |
native int | muteLocalAudio (int connId, boolean mute) |
native int | muteLocalVideo (int connId, boolean mute) |
native int | muteRemoteAudio (int connId, int remoteUid, boolean mute) |
native int | muteRemoteVideo (int connId, int uid, boolean mute) |
*native int | requestVideoKeyFrame (int connId, int remoteUid, int streamType) |
native int | sendAudioData (int connId, byte[] data, AudioFrameInfo info) |
native int | sendVideoData (int connId, byte[] data, VideoFrameInfo info) |
native int | setBweParam (int connId, int miniBps, int maxBps, int startBps) |
native int | setParams (String params) |
native int | setCloudProxy (int type) |
native int | loginRtm (String rtmUid, String rtmToken, AgoraRtmEvents events) |
native int | logoutRtm () |
native int | sendRtm (String rtmUid, int messageId, byte[] message) |
AgoraRtcService 类包含应用程序调用的所有方法。
native int io.agora.rtc.AgoraRtcService.configLog | ( | int | sizePerFile, |
int | maxFileCount | ||
) |
配置 SDK 的日志文件。
sizePerFile | 每份日志文件的大小(字节)。取值范围为 [10000, 1000000]。 |
maxFileCount | 日志文件数。取值范围为 [1, 100]。 |
native int io.agora.rtc.AgoraRtcService.createConnection | ( | ) |
创建 Connection。
native int io.agora.rtc.AgoraRtcService.destroyConnection | ( | int | connId | ) |
销毁 Connection。
connId | Connection ID。一个 Connection 可以连接多个 RTC 频道。设为 CONNECTION_ID_ALL 表示针对当前创建的所有 Connection 。你可以通过 createConnection 创建 Connection。 |
native String io.agora.rtc.AgoraRtcService.errToStr | ( | int | err | ) |
将错误码转换为静态字符串。
err | 错误码。 |
native int io.agora.rtc.AgoraRtcService.fini | ( | ) |
释放所有由 init 方法分配给 SDK 的资源。
native int io.agora.rtc.AgoraRtcService.getConnectionInfo | ( | int | connId, |
ConnectionInfo | connInfo | ||
) |
获取 Connection 信息。
connId | Connection ID。一个 Connection 可以连接多个 RTC 频道。设为 CONNECTION_ID_ALL 表示针对当前创建的所有 Connection 。你可以通过 createConnection 创建 Connection。 |
connInfo | 连接信息。详见 ConnectionInfo。 |
native String io.agora.rtc.AgoraRtcService.getVersion | ( | ) |
获取 SDK 版本。
native int io.agora.rtc.AgoraRtcService.init | ( | String | appId, |
AgoraRtcEvents | events, | ||
RtcServiceOptions | options | ||
) |
初始化 SDK。
appId | 声网为 App 开发者签发的 APP ID。 |
events | 用于处理 SDK 事件的一系列回调。 |
options | 服务配置选项,如果不需要设置则请置空。 |
native int io.agora.rtc.AgoraRtcService.joinChannel | ( | int | connId, |
String | channelName, | ||
int | uid, | ||
String | token, | ||
ChannelOptions | options | ||
) |
加入频道。
该方法让用户加入指定频道。同一个频道内使用相同 App ID 的用户可以互相传输数据。
connId | Connection ID。一个 Connection 可以连接多个 RTC 频道。设为 CONNECTION_ID_ALL 表示针对当前创建的所有 Connection 。你可以通过 createConnection 创建 Connection。 |
channelName | 频道名,长度在 64 字节以内的字符串。以下为支持的字符集范围(共 89 个字符):
|
uid | 用户 ID。 |
token | 用于鉴权的 Token。
|
options | 频道设置选项。 |
native int io.agora.rtc.AgoraRtcService.leaveChannel | ( | int | connId | ) |
退出频道。
停止在某频道传输数据后需要离开该频道。
connId | Connection ID。一个 Connection 可以连接多个 RTC 频道。设为 CONNECTION_ID_ALL 表示针对当前创建的所有 Connection 。你可以通过 createConnection 创建 Connection。 |
native String io.agora.rtc.AgoraRtcService.licenseGenCredential | ( | ) |
生成设备唯一标识 Credential。
native int io.agora.rtc.AgoraRtcService.licenseVerify | ( | String | certificate, |
String | credential | ||
) |
认证 SDK。
certificate | 许可证 Certificate。 |
credential | 凭证 Credential。 |
native int io.agora.rtc.AgoraRtcService.loginRtm | ( | String | rtmUid, |
String | rtmToken, | ||
AgoraRtmEvents | events | ||
) |
登录云信令 (原 RTM) 服务。
rtmUid | 云信令 (原 RTM) 用户 ID。该字符串不可超过 64 字节。不可设为空、NULL 或 "NULL" 。以下为支持的字符集范围:
|
rtmToken | 用于登录云信令 (原 RTM) 系统的动态密钥。详见《校验用户权限》。如果你没有开启 Token 鉴权,此参数可设为 NULL 。 |
events | 云信令 (原 RTM) 回调。 |
native int io.agora.rtc.AgoraRtcService.logoutRtm | ( | ) |
登出云信令 (原 RTM) 服务。
native int io.agora.rtc.AgoraRtcService.muteLocalAudio | ( | int | connId, |
boolean | mute | ||
) |
暂停/恢复发送本地音频流。
可以先暂停向所有频道发送音频流,然后恢复向指定频道发送音频流。
connId | Connection ID。一个 Connection 可以连接多个 RTC 频道。设为 CONNECTION_ID_ALL 表示针对当前创建的所有 Connection 。你可以通过 createConnection 创建 Connection。 |
mute | 设置是否暂停/恢复发送本地音频流:
|
native int io.agora.rtc.AgoraRtcService.muteLocalVideo | ( | int | connId, |
boolean | mute | ||
) |
暂停/恢复发送本地视频流。
可以先暂停向所有频道发送视频流,然后恢复向指定频道发送视频流。
connId | Connection ID。一个 Connection 可以连接多个 RTC 频道。设为 CONNECTION_ID_ALL 表示针对当前创建的所有 Connection 。你可以通过 createConnection 创建 Connection。 |
mute | 设置是否暂停/恢复发送本地视频流:
|
native int io.agora.rtc.AgoraRtcService.muteRemoteAudio | ( | int | connId, |
int | remoteUid, | ||
boolean | mute | ||
) |
暂停/恢复接收指定频道内指定远端用户的音频流。
可以先暂停接收所有频道的音频流,然后恢复接收某个指定频道的音频流。
connId | Connection ID。一个 Connection 可以连接多个 RTC 频道。设为 CONNECTION_ID_ALL 表示针对当前创建的所有 Connection 。你可以通过 createConnection 创建 Connection。 |
remoteUid | 指定用户的用户 ID。设为 0 则停止接收频道内所有用户的音频流。 |
mute | 设置是否暂停/恢复接收远端音频流:
|
native int io.agora.rtc.AgoraRtcService.muteRemoteVideo | ( | int | connId, |
int | uid, | ||
boolean | mute | ||
) |
暂停/恢复接收指定频道内指定远端用户的视频流。
可以先暂停接收所有频道的视频流,然后恢复接收指定频道的视频流。
connId | Connection ID。一个 Connection 可以连接多个 RTC 频道。设为 CONNECTION_ID_ALL 表示针对当前创建的所有 Connection 。你可以通过 createConnection 创建 Connection。 |
uid | 指定用户的用户 ID。设为 0 则停止接收频道内所有用户的视频流。 |
mute | 设置是否暂停/恢复接收远端视频流:
|
native int io.agora.rtc.AgoraRtcService.notifyNetworkEvent | ( | int | event | ) |
向 SDK 报告网络状态。
对于 Android 11 或更高版本,SDK 无法自动处理网络事件变更。你可以通过该方法向 SDK 报告网络状态。 SDK 会根据网络事件进行相应操作,例如尝试重新加入 RTC 频道和登录 RTM 系统。
event | 网络事件,详见 NetworkEventType 。
|
native int io.agora.rtc.AgoraRtcService.renewToken | ( | int | connId, |
String | token | ||
) |
更新指定频道或全部频道的 Token。
connId | Connection ID。一个 Connection 可以连接多个 RTC 频道。设为 CONNECTION_ID_ALL 表示针对当前创建的所有 Connection 。你可以通过 createConnection 创建 Connection。 |
token | 新生成的 Token。 |
*native int io.agora.rtc.AgoraRtcService.requestVideoKeyFrame | ( | int | connId, |
int | remoteUid, | ||
int | streamType | ||
) |
请求指定远端用户尽快为指定远端视频流生成关键帧。
connId | Connection ID。一个 Connection 可以连接多个 RTC 频道。设为 CONNECTION_ID_ALL 表示针对当前创建的所有 Connection 。你可以通过 createConnection 创建 Connection。 |
remoteUid | 需要生成关键帧的用户 ID。如果为频道内的所有用户,则设为 0。 |
streamType | 需要生成关键帧的视频流类型。详见 VideoStreamType。 |
native int io.agora.rtc.AgoraRtcService.sendAudioData | ( | int | connId, |
byte[] | data, | ||
AudioFrameInfo | info | ||
) |
向加入的频道发送音频帧。
频道内所有用户都能收到你发出的音频帧。
connId | Connection ID。一个 Connection 可以连接多个 RTC 频道。设为 CONNECTION_ID_ALL 表示针对当前创建的所有 Connection 。你可以通过 createConnection 创建 Connection。 |
data | 音频包数据。 |
info | 音频帧信息。 |
native int io.agora.rtc.AgoraRtcService.sendRtm | ( | String | rtmUid, |
int | messageId, | ||
byte[] | message | ||
) |
通过云信令 (原 RTM) 服务发送消息。
onRtmEvent
回调时才可以发送消息。发送频率不能超过每 3 秒 180 条。rtmUid | 云信令 (原 RTM) 用户 ID。 |
messageId | 消息 ID。 |
message | 消息内容。仅支持 UTF-8 编码。 |
native int io.agora.rtc.AgoraRtcService.sendVideoData | ( | int | connId, |
byte[] | data, | ||
VideoFrameInfo | info | ||
) |
向加入的频道发送视频帧。
频道内所有用户都能收到你发出的视频帧。
connId | Connection ID。一个 Connection 可以连接多个 RTC 频道。设为 CONNECTION_ID_ALL 表示针对当前创建的所有 Connection 。你可以通过 createConnection 创建 Connection。 |
data | 视频包数据。 |
info | 视频帧信息。 |
native int io.agora.rtc.AgoraRtcService.setBweParam | ( | int | connId, |
int | miniBps, | ||
int | maxBps, | ||
int | startBps | ||
) |
设置 bandwidth estimation (BWE) 参数。
connId | Connection ID。一个 Connection 可以连接多个 RTC 频道。设为 CONNECTION_ID_ALL 表示针对当前创建的所有 Connection 。你可以通过 createConnection 创建 Connection。 |
miniBps | 最小码率,单位为 bps。 |
maxBps | 最大码率,单位为 bps。 |
startBps | 起始码率,单位为 bps。 |
native int io.agora.rtc.AgoraRtcService.setCloudProxy | ( | int | type | ) |
设置声网云代理服务。
type | 云代理类型。
|
native int io.agora.rtc.AgoraRtcService.setLogLevel | ( | int | level | ) |
native int io.agora.rtc.AgoraRtcService.setParams | ( | String | params | ) |
通过 JSON 配置 SDK 提供技术预览或特别定制功能。
JSON 选项默认不公开。声网工程师正在努力寻求以标准化方式公开 JSON 选项。
params | JSON 字符串形式的参数。 |