#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
结构体 | |
struct | video_frame_info_t |
struct | audio_frame_info_t |
struct | log_config_t |
struct | rtc_service_option_t |
struct | audio_codec_option_t |
struct | rtc_audio_process_options_t |
struct | rtc_channel_options_t |
struct | connection_info_t |
struct | agora_rtc_event_handler_t |
struct | agora_rtm_handler_t |
宏定义 | |
#define | __agora_api__ |
#define | AGORA_RTC_CHANNEL_NAME_MAX_LEN (64) |
#define | AGORA_RTC_USER_ID_MAX_LEN (255) |
#define | AGORA_RTC_PRODUCT_ID_MAX_LEN (63) |
#define | AGORA_RTM_UID_MAX_LEN 64 |
#define | AGORA_RTM_DATA_MAX_LEN (32 * 1024) |
#define | AGORA_CREDENTIAL_MAX_LEN 256 |
#define | AGORA_CERTIFICATE_MAX_LEN 1024 |
#define | AGORA_LICENSE_VALUE_LEN 32 |
#define | CONNECTION_ID_ALL ((connection_id_t)0) |
#define | CONNECTION_ID_INVALID ((connection_id_t)-1) |
类型定义 | |
typedef uint32_t | connection_id_t |
#define __agora_api__ |
#define AGORA_CERTIFICATE_MAX_LEN 1024 |
#define AGORA_CREDENTIAL_MAX_LEN 256 |
#define AGORA_LICENSE_VALUE_LEN 32 |
#define AGORA_RTC_CHANNEL_NAME_MAX_LEN (64) |
#define AGORA_RTC_PRODUCT_ID_MAX_LEN (63) |
#define AGORA_RTC_USER_ID_MAX_LEN (255) |
#define AGORA_RTM_DATA_MAX_LEN (32 * 1024) |
#define AGORA_RTM_UID_MAX_LEN 64 |
#define CONNECTION_ID_ALL ((connection_id_t)0) |
当前创建的全部 Connection。
#define CONNECTION_ID_INVALID ((connection_id_t)-1) |
无效的 Connection ID。
typedef uint32_t connection_id_t |
Connection ID。
enum agora_err_code_e |
错误码。
枚举值 | |
---|---|
ERR_OKAY | 0: 无错误。 |
ERR_FAILED | 1: 通用错误。你可以根据日志文件排查问题。 |
ERR_NET_DOWN | 14: 网络不可用。你需要检查系统网络连接状态。 |
ERR_JOIN_CHANNEL_REJECTED | 17: 加入频道请求被拒绝,可能是因为本地用户已在频道内。你需要调整代码逻辑,避免用户加入同一频道。 |
ERR_INVALID_APP_ID | 101: App ID 无效。你需要检查 App ID 是否符合要求。 |
ERR_INVALID_CHANNEL_NAME | 102: 频道名无效。你需要检查频道名是否符合要求。 |
ERR_NO_SERVER_RESOURCES | 103: 在当前的区域限制码条件下无可用服务器资源。 |
ERR_LOOKUP_CHANNEL_REJECTED | 105: 声网服务器拒绝了查询频道的请求。你需要检查 RTC Token 是否有效。 |
ERR_OPEN_CHANNEL_REJECTED | 107: 声网服务器拒绝了创建频道的请求。你需要检查 RTC Token 是否有效。 |
ERR_TOKEN_EXPIRED | 109: 当前使用的 RTC Token 已过期。你需要重新在服务端申请生成 RTC Token 并调用 agora_rtc_join_channel 使用新生成的 RTC Token 重新加入频道。 |
ERR_INVALID_TOKEN | 110: RTC Token 无效。你需要检查生成 token 使用的 uid 是否和加入频道时使用的 uid 一致。 |
ERR_DYNAMIC_TOKEN_BUT_USE_STATIC_KEY | 115: 你在声网控制台开启了 App 证书,但仍旧在代码里仅使用了 App ID。当启用了 App Certificate,必须使用 RTC Token。 |
ERR_SET_CLIENT_ROLE_NOT_AUTHORIZED | 119: 切换用户角色失败,请尝试重新加入频道。 |
ERR_DECRYPTION_FAILED | 120:解密失败。检查你的加密设置或重新加入频道。 |
ERR_OPEN_CHANNEL_INVALID_TICKET | 121: 打开频道的信令错误。请尝试重新加入频道。 |
ERR_OPEN_CHANNEL_TRY_NEXT_VOS | 122: 系统在尝试切换服务器。通常不需要额外处理,系统会自动尝试切换服务器以打开频道。 |
ERR_CLIENT_IS_BANNED_BY_SERVER | 123: 该客户端被服务器禁用。你需要检查该用户是否被踢。 |
ERR_SEND_VIDEO_OVER_BANDWIDTH_LIMIT | 200: 视频帧发送速率超过带宽限制。可能会造成丢包。你可以通过 |
ERR_AUDIO_DECODER_NOT_MATCH_AUDIO_FRAME | 201:设置的编码类型与实际编码类型不符导致 SDK 解码失败。你需要确认 SDK 设置的编码类型是否与实际传输的编码类型一致。 |
ERR_NO_AUDIO_DECODER_TO_HANDLE_AUDIO_FRAME | 202: SDK 解码失败。SDK 内置的解码器仅支持 Opus、G722 和 PCMU 编码的音频帧。你需要确认对端发送的音频码流是否为 Opus 、G722 或 PCMU 编码格式。 |
enum area_code_e |
enum audio_codec_type_e |
SDK 内置的音频编解码器。
enum audio_data_type_e |
enum cloud_proxy_type_e |
enum license_err_reason_e |
设备 License 验证失败的错误码。
枚举值 | |
---|---|
ERR_LICENSE_INVALID | 1: 无效 License。你需要重新调用 agora_rtc_init 并在 rtc_service_option_t 的 |
ERR_LICENSE_EXPIRE | 2: License 过期。你需要联系 iot@a 进行续费。 gora .io |
ERR_LICENSE_MINUTES_EXCEED | 3: License 包含的通话时长已用完。你需要联系 iot@a 购买通话时长更长的 License。 gora .io |
ERR_LICENSE_LIMITED_PERIOD | 4: 当前时间段受 License 限制,不能进行通话。你需要换一个 License 允许的时间段进行通话,或联系 iot@a 购买通话时间段更长的 License。 gora .io |
ERR_LICENSE_DIFF_DEVICES | 5: License 已在其他设备中使用。一个 License 只允许在一台设备中使用,你需要重新调用 agora_rtc_init 并在 rtc_service_option_t 的 |
ERR_LICENSE_INTERNAL | 99: 内部原因。 |
enum network_event_type_e |
enum rtc_log_level_e |
日志输出级别。
enum rtm_err_code_e |
enum rtm_event_type_e |
enum video_data_type_e |
enum video_frame_rate_e |
enum video_frame_type_e |
enum video_orientation_e |
enum video_stream_type_e |
__agora_api__ int agora_rtc_config_log | ( | int | size_per_file, |
int | max_file_count | ||
) |
配置 SDK 的日志文件。
[in] | size_per_file | 每份日志文件的大小(字节)。取值范围为 [0, 10*1024*1024]。默认值为 1*1024*1024,即 1 MB。如果你将此参数设为 0,则代表关闭日志功能。 |
[in] | max_file_count | 日志文件数。取值范围为 [0, 100]。默认值为 10。如果你将此参数设为 0,则代表关闭日志功能。 |
__agora_api__ int agora_rtc_create_connection | ( | connection_id_t * | conn_id | ) |
创建 Connection。
[out] | conn_id | Connection ID。一个 Connection 可以连接多个 RTC 频道。 |
__agora_api__ int agora_rtc_destroy_connection | ( | connection_id_t | conn_id | ) |
销毁 Connection。
[in] | conn_id | Connection ID。一个 Connection 可以连接多个 RTC 频道。设为 CONNECTION_ID_ALL 表示针对当前创建的所有 Connection 。你可以通过 agora_rtc_create_connection 创建 Connection。 |
__agora_api__ const char * agora_rtc_err_2_str | ( | int | err | ) |
将错误码转为静态字符串,以便查看错误描述。
[in] | err | 错误码。 |
__agora_api__ int agora_rtc_fini | ( | void | ) |
释放所有由 agora_rtc_init 方法分配给 RTSA 服务的资源。
__agora_api__ int agora_rtc_get_connection_info | ( | connection_id_t | conn_id, |
connection_info_t * | conn_info | ||
) |
获取 Connection 信息。
[in] | conn_id | Connection ID。一个 Connection 可以连接多个 RTC 频道。你可以通过 agora_rtc_create_connection 创建 Connection。 |
[out] | conn_info | Connection 信息。详见 connection_info_t 。 |
const char * agora_rtc_get_version | ( | void | ) |
获取 SDK 版本。
__agora_api__ int agora_rtc_init | ( | const char * | app_id, |
const agora_rtc_event_handler_t * | event_handler, | ||
rtc_service_option_t * | option | ||
) |
初始化 RTSA 服务。
[in] | app_id | 声网为 App 开发者签发的 APP ID。 |
[in] | event_handler | 用于处理 SDK 事件的一系列回调。详见 agora_rtc_event_handler_t 。 |
[in] | option | 服务配置选项,如果不需要设置则请置空。详见 rtc_service_option_t 。 |
__agora_api__ int agora_rtc_join_channel | ( | connection_id_t | conn_id, |
const char * | channel_name, | ||
uint32_t | uid, | ||
const char * | token, | ||
rtc_channel_options_t * | options | ||
) |
加入指定 Connection 所关联的 RTC 频道。
该方法让本地用户加入指定频道。同一个频道内使用相同 App ID 的用户可以互相传输数据。
[in] | conn_id | Connection ID。一个 Connection 可以连接多个 RTC 频道。设为 CONNECTION_ID_ALL 表示针对当前创建的所有 Connection 。你可以通过 agora_rtc_create_connection 创建 Connection。 |
[in] | channel_name | 频道名,长度在 64 字节以内的字符串。以下为支持的字符集范围(共 89 个字符):
|
[in] | uid | 用户 ID。 |
[in] | token | 用于鉴权的 RTC Token。
|
[in] | options | 频道设置选项。详见 rtc_channel_options_t 。 |
__agora_api__ int agora_rtc_leave_channel | ( | connection_id_t | conn_id | ) |
离开指定 Connection 所关联的 RTC 频道。
停止在某频道传输数据后需要离开该频道。
[in] | conn_id | Connection ID。一个 Connection 可以连接多个 RTC 频道。设为 CONNECTION_ID_ALL 表示针对当前创建的所有 Connection 。你可以通过 agora_rtc_create_connection 创建 Connection。 |
__agora_api__ int agora_rtc_license_gen_credential | ( | char * | credential, |
unsigned int * | credential_len | ||
) |
生成设备唯一标识 Credential。
[out] | credential | 用于存放 Credential 的缓冲区。 |
[in,out] | credential_len | 缓冲区大小(字节)。
|
__agora_api__ int agora_rtc_license_verify | ( | const char * | certificate, |
int | certificate_len, | ||
const char * | credential, | ||
int | credential_len | ||
) |
认证 SDK。
启用了 Agora License 机制后,安装了 SDK 的设备只有通过 Certificate 验证 才能加入声网频道、使用数据传输功能。
[in] | certificate | 许可证 Certificate。 |
[in] | certificate_len | 许可证长度。 |
[in] | credential | 凭证 Credential。 |
[in] | credential_len | 凭证长度。 |
__agora_api__ int agora_rtc_login_rtm | ( | const char * | rtm_uid, |
const char * | rtm_token, | ||
const agora_rtm_handler_t * | handler | ||
) |
登录云信令 (原 RTM) 服务。
[in] | rtm_uid | 云信令 (原 RTM) 用户 ID。该字符串不可超过 64 字节。不可设为空、NULL 或 "NULL" 。以下为支持的字符集范围:
|
[in] | rtm_token | 用于登录云信令 (原 RTM) 系统的动态密钥。详见《校验用户权限》。如果你没有开启 Token 鉴权,此参数可设为 NULL 。 |
[in] | handler | 云信令 (原 RTM) 回调。详见 agora_rtm_handler_t 。 |
__agora_api__ int agora_rtc_logout_rtm | ( | void | ) |
登出云信令 (原 RTM) 服务。
__agora_api__ int agora_rtc_mute_local_audio | ( | connection_id_t | conn_id, |
bool | mute | ||
) |
对指定 Connection 所关联的 RTC 频道暂停/恢复发送本地音频流。
[in] | conn_id | Connection ID。一个 Connection 可以连接多个 RTC 频道。设为 CONNECTION_ID_ALL 表示针对当前创建的所有 Connection 。你可以通过 agora_rtc_create_connection 创建 Connection。 |
[in] | mute | 暂停/恢复发送本地音频流:
|
__agora_api__ int agora_rtc_mute_local_video | ( | connection_id_t | conn_id, |
bool | mute | ||
) |
指定 Connection 所关联的 RTC 频道暂停/恢复发送本地视频流。
[in] | conn_id | Connection ID。一个 Connection 可以连接多个 RTC 频道。设为 CONNECTION_ID_ALL 表示针对当前创建的所有 Connection 。你可以通过 agora_rtc_create_connection 创建 Connection。 |
[in] | mute | 暂停/恢复发送本地视频流:
|
__agora_api__ int agora_rtc_mute_remote_audio | ( | connection_id_t | conn_id, |
uint32_t | remote_uid, | ||
bool | mute | ||
) |
暂停/恢复接收指定 Connection 所关联的 RTC 频道内的指定远端用户的音频流。
[in] | conn_id | Connection ID。一个 Connection 可以连接多个 RTC 频道。设为 CONNECTION_ID_ALL 表示针对当前创建的所有 Connection 。你可以通过 agora_rtc_create_connection 创建 Connection。 |
[in] | remote_uid | 远端用户 ID。设为 0 则停止接收频道内所有用户的音频流。 |
[in] | mute | 暂停/恢复接收远端音频流:
|
__agora_api__ int agora_rtc_mute_remote_video | ( | connection_id_t | conn_id, |
uint32_t | remote_uid, | ||
bool | mute | ||
) |
暂停/恢复接收指定 Connection 所关联的 RTC 频道内的指定远端用户的视频流。
可以先暂停接收所有频道的视频流,然后恢复接收指定频道的视频流。
[in] | conn_id | Connection ID。一个 Connection 可以连接多个 RTC 频道。设为 CONNECTION_ID_ALL 表示针对当前创建的所有 Connection 。你可以通过 agora_rtc_create_connection 创建 Connection。 |
[in] | remote_uid | 远端用户 ID。设为 0 则停止接收频道内所有用户的视频流。 |
[in] | mute | 暂停/恢复接收远端视频流:
|
__agora_api__ int agora_rtc_notify_network_event | ( | network_event_type_e | event | ) |
__agora_api__ int agora_rtc_renew_token | ( | connection_id_t | conn_id, |
const char * | token | ||
) |
更新指定 Connection 所关联的 RTC 频道的 RTC Token。
[in] | conn_id | Connection ID。一个 Connection 可以连接多个 RTC 频道。设为 CONNECTION_ID_ALL 表示针对当前创建的所有 Connection 。你可以通过 agora_rtc_create_connection 创建 Connection。 |
[in] | token | 声网 RTC Token。 |
__agora_api__ int agora_rtc_request_video_key_frame | ( | connection_id_t | conn_id, |
uint32_t | remote_uid, | ||
video_stream_type_e | stream_type | ||
) |
请求指定 Connection 所关联的 RTC 频道内的指定远端用户为指定远端视频流生成关键帧。
[in] | conn_id | Connection ID。一个 Connection 可以连接多个 RTC 频道。设为 CONNECTION_ID_ALL 表示针对当前创建的所有 Connection 。你可以通过 agora_rtc_create_connection 创建 Connection。 |
[in] | remote_uid | 远端用户 ID。如果为频道内的所有用户,则设为 0。 |
[in] | stream_type | 视频流类型。详见 video_stream_type_e 。 |
__agora_api__ int agora_rtc_send_audio_data | ( | connection_id_t | conn_id, |
const void * | data_ptr, | ||
size_t | data_len, | ||
audio_frame_info_t * | info_ptr | ||
) |
向指定 Connection 所关联的 RTC 频道发送音频帧。
[in] | conn_id | Connection ID。一个 Connection 可以连接多个 RTC 频道。设为 CONNECTION_ID_ALL 表示针对当前创建的所有 Connection 。你可以通过 agora_rtc_create_connection 创建 Connection。 |
[in] | data_ptr | 音频包数据。 |
[in] | data_len | 音频包数据大小(字节)。 |
[in] | info_ptr | 音频帧配置,详见 audio_frame_info_t 。 |
__agora_api__ int agora_rtc_send_rtm_data | ( | const char * | rtm_uid, |
uint32_t | msg_id, | ||
const void * | msg, | ||
size_t | msg_len | ||
) |
通过云信令 (原 RTM) 服务发送消息。
[in] | rtm_uid | 云信令 (原 RTM) 用户 ID。 |
[in] | msg_id | 消息 ID。 |
[in] | msg | 消息内容。仅支持 UTF-8 编码。 |
[in] | msg_len | 消息长度,单位是字节。最大不得超过 32 KB。 |
__agora_api__ int agora_rtc_send_video_data | ( | connection_id_t | conn_id, |
const void * | data_ptr, | ||
size_t | data_len, | ||
video_frame_info_t * | info_ptr | ||
) |
向指定 Connection 所关联的 RTC 频道发送视频帧。
[in] | conn_id | Connection ID。一个 Connection 可以连接多个 RTC 频道。设为 CONNECTION_ID_ALL 表示针对当前创建的所有 Connection 。你可以通过 agora_rtc_create_connection 创建 Connection。 |
[in] | data_ptr | 视频包数据。 |
[in] | data_len | 视频包数据大小(字节)。 |
[in] | info_ptr | 视频帧配置,详见 video_frame_info_t 。 |
__agora_api__ int agora_rtc_set_bwe_param | ( | connection_id_t | conn_id, |
uint32_t | min_bps, | ||
uint32_t | max_bps, | ||
uint32_t | start_bps | ||
) |
设置 bandwidth estimation (BWE) 参数。
[in] | conn_id | Connection ID。一个 Connection 可以连接多个 RTC 频道。设为 CONNECTION_ID_ALL 表示针对当前创建的所有 Connection 。你可以通过 agora_rtc_create_connection 创建 Connection。 |
[in] | min_bps | 最小码率,单位为 bps。 |
[in] | max_bps | 最大码率,单位为 bps。 |
[in] | start_bps | 起始码率,单位为 bps。 |
__agora_api__ int agora_rtc_set_cloud_proxy | ( | cloud_proxy_type_e | type | ) |
__agora_api__ int agora_rtc_set_log_level | ( | rtc_log_level_e | level | ) |
设置 SDK 的日志输出等级。
设置一个级别后,你可以看到该级别及之前所有级别的日志信息。
[in] | level | 日志输出等级。详见 rtc_log_level_e 。 |
__agora_api__ int agora_rtc_set_params | ( | const char * | params | ) |
通过 JSON 配置 SDK 提供技术预览或特别定制功能。
JSON 选项默认不公开。声网工程师正在努力寻求以标准化方式公开 JSON 选项。
[in] | params | : JSON 字符串形式的参数。 |