Cocos2d-x(C++ 绑定) API 参考
构建时从公开 SDK 接口定义生成:接口、方法重载、属性、事件、枚举与错误码。
接口概览
本页列出 Cocos2d-x(C++ 绑定) 端公开 API 的类、方法、重载、属性、事件与错误码,接口定义与 SDK 包版本一致。
| 核对项 | 数量 |
|---|---|
| 接口 / 类 | 2 |
| 方法 | 43 |
| 方法重载 | 48 |
| 属性 | 0 |
| 枚举 | 0 |
| 错误码常量 | 0 |
可用性
该端 SDK:正式可用。接口定义与 SDK 包版本一致;运行时的能力边界以实际发布的 SDK 包为准。
加入频道核心链路
按 join / leave / publish / subscribe 的典型调用顺序整理;参数表在“最小可运行链路”一节展开。
| 步骤 | 接口 | 方法 | 重载数 |
|---|---|---|---|
| 开启视频与预览 | NimeetCocos2dxRtcEngine | enableVideo | 1 |
| 创建 / 初始化 | NimeetCocos2dxRtcEngine | initialize | 1 |
| 加入频道 | NimeetCocos2dxRtcEngine | joinChannel | 2 |
| 离开频道 | NimeetCocos2dxRtcEngine | leaveChannel | 2 |
| 订阅远端媒体 | NimeetCocos2dxRtcEngine | muteRemoteAudioStream | 1 |
| 续期 Token | NimeetCocos2dxRtcEngine | renewToken | 1 |
| 频道场景 | NimeetCocos2dxRtcEngine | setChannelProfile | 1 |
| 角色切换 | NimeetCocos2dxRtcEngine | setClientRole | 2 |
| 本地画面 | NimeetCocos2dxRtcEngine | setupLocalVideo | 1 |
最小可运行链路的参数
| 参数 | 类型 | 可选 | 可变参数 |
|---|---|---|---|
context | const RtcEngineContext& | 否 | 否 |
token | const char* | 否 | 否 |
channelId | const char* | 否 | 否 |
info | const char* | 否 | 否 |
uid | uid_t | 否 | 否 |
token | const char* | 否 | 否 |
channelId | const char* | 否 | 否 |
uid | uid_t | 否 | 否 |
options | const ChannelMediaOptions& | 否 | 否 |
options | const LeaveChannelOptions& | 否 | 否 |
uid | uid_t | 否 | 否 |
mute | bool | 否 | 否 |
token | const char* | 否 | 否 |
profile | CHANNEL_PROFILE_TYPE | 否 | 否 |
role | CLIENT_ROLE_TYPE | 否 | 否 |
role | CLIENT_ROLE_TYPE | 否 | 否 |
options | const ClientRoleOptions& | 否 | 否 |
canvas | const VideoCanvas& | 否 | 否 |
接口索引
| 接口 | 方法 | 属性 | 事件 |
|---|---|---|---|
IRtcEngineEventHandler | 14 | 0 | 0 |
NimeetCocos2dxRtcEngine | 29 | 0 | 0 |
全部接口
IRtcEngineEventHandler 14 方法 / 0 属性
onAudioVolumeIndication(speakers: const AudioVolumeInfo*, speakerNumber: unsigned int, totalVolume: int): void
onConnectionStateChanged(state: CONNECTION_STATE_TYPE, reason: CONNECTION_CHANGED_REASON_TYPE): void
onError(err: int, msg: const char*): void
onJoinChannelSuccess(channel: const char*, uid: uid_t, elapsed: int): void
onLeaveChannel(stats: const RtcStats&): void
onLocalAudioStateChanged(state: LOCAL_AUDIO_STREAM_STATE, reason: LOCAL_AUDIO_STREAM_REASON): void
onLocalVideoStateChanged(source: VIDEO_SOURCE_TYPE, state: LOCAL_VIDEO_STREAM_STATE, reason: LOCAL_VIDEO_STREAM_REASON): void
onRejoinChannelSuccess(channel: const char*, uid: uid_t, elapsed: int): void
onRemoteAudioStateChanged(uid: uid_t, state: REMOTE_AUDIO_STATE, reason: REMOTE_AUDIO_STATE_REASON, elapsed: int): void
onRemoteVideoStateChanged(uid: uid_t, state: REMOTE_VIDEO_STATE, reason: REMOTE_VIDEO_STATE_REASON, elapsed: int): void
onRequestToken(): void
onRtcStats(stats: const RtcStats&): void
onUserJoined(uid: uid_t, elapsed: int): void
onUserOffline(uid: uid_t, reason: USER_OFFLINE_REASON_TYPE): void方法明细:14 / 14(参数、返回值、错误码)
| 方法 | 参数 | 返回值 | 错误 |
|---|---|---|---|
onAudioVolumeIndication | speakers: const AudioVolumeInfo*, speakerNumber: unsigned int, totalVolume: int | void | 错误码索引 |
onConnectionStateChanged | state: CONNECTION_STATE_TYPE, reason: CONNECTION_CHANGED_REASON_TYPE | void | 错误码索引 |
onError | err: int, msg: const char* | void | 错误码索引 |
onJoinChannelSuccess | channel: const char*, uid: uid_t, elapsed: int | void | 错误码索引 |
onLeaveChannel | stats: const RtcStats& | void | 错误码索引 |
onLocalAudioStateChanged | state: LOCAL_AUDIO_STREAM_STATE, reason: LOCAL_AUDIO_STREAM_REASON | void | 错误码索引 |
onLocalVideoStateChanged | source: VIDEO_SOURCE_TYPE, state: LOCAL_VIDEO_STREAM_STATE, reason: LOCAL_VIDEO_STREAM_REASON | void | 错误码索引 |
onRejoinChannelSuccess | channel: const char*, uid: uid_t, elapsed: int | void | 错误码索引 |
onRemoteAudioStateChanged | uid: uid_t, state: REMOTE_AUDIO_STATE, reason: REMOTE_AUDIO_STATE_REASON, elapsed: int | void | 错误码索引 |
onRemoteVideoStateChanged | uid: uid_t, state: REMOTE_VIDEO_STATE, reason: REMOTE_VIDEO_STATE_REASON, elapsed: int | void | 错误码索引 |
onRequestToken | — | void | 错误码索引 |
onRtcStats | stats: const RtcStats& | void | 错误码索引 |
onUserJoined | uid: uid_t, elapsed: int | void | 错误码索引 |
onUserOffline | uid: uid_t, reason: USER_OFFLINE_REASON_TYPE | void | 错误码索引 |
NimeetCocos2dxRtcEngine 29 方法 / 0 属性
adjustPlaybackSignalVolume(volume: int): int
adjustRecordingSignalVolume(volume: int): int
disableAudio(): int
disableVideo(): int
enableAudio(): int
enableAudioVolumeIndication(interval: int, smooth: int, reportVad: bool): int
enableLocalAudio(enabled: bool): int
enableLocalVideo(enabled: bool): int
enableVideo(): int
initialize(context: const RtcEngineContext&): int
joinChannel(token: const char*, channelId: const char*, info: const char*, uid: uid_t): int
joinChannel(token: const char*, channelId: const char*, uid: uid_t, options: const ChannelMediaOptions&): int
leaveChannel(): int
leaveChannel(options: const LeaveChannelOptions&): int
muteAllRemoteAudioStreams(mute: bool): int
muteAllRemoteVideoStreams(mute: bool): int
muteLocalAudioStream(mute: bool): int
muteLocalVideoStream(mute: bool): int
muteRemoteAudioStream(uid: uid_t, mute: bool): int
muteRemoteVideoStream(uid: uid_t, mute: bool): int
renewToken(token: const char*): int
setChannelProfile(profile: CHANNEL_PROFILE_TYPE): int
setClientRole(role: CLIENT_ROLE_TYPE): int
setClientRole(role: CLIENT_ROLE_TYPE, options: const ClientRoleOptions&): int
setLogFilter(filter: unsigned int): int
setParameters(parameters: const char*): int
setVideoEncoderConfiguration(config: const VideoEncoderConfiguration&): int
setupLocalVideo(canvas: const VideoCanvas&): int
setupRemoteVideo(canvas: const VideoCanvas&): int
startPreview(): int
startPreview(sourceType: VIDEO_SOURCE_TYPE): int
stopPreview(): int
stopPreview(sourceType: VIDEO_SOURCE_TYPE): int
switchCamera(): int方法明细:29 / 29(参数、返回值、错误码)
| 方法 | 参数 | 返回值 | 错误 |
|---|---|---|---|
adjustPlaybackSignalVolume | volume: int | int | 错误码索引 |
adjustRecordingSignalVolume | volume: int | int | 错误码索引 |
disableAudio | — | int | 错误码索引 |
disableVideo | — | int | 错误码索引 |
enableAudio | — | int | 错误码索引 |
enableAudioVolumeIndication | interval: int, smooth: int, reportVad: bool | int | 错误码索引 |
enableLocalAudio | enabled: bool | int | 错误码索引 |
enableLocalVideo | enabled: bool | int | 错误码索引 |
enableVideo | — | int | 错误码索引 |
initialize | context: const RtcEngineContext& | int | 错误码索引 |
joinChannel | token: const char*, channelId: const char*, info: const char*, uid: uid_t | int | 错误码索引 |
leaveChannel | — | int | 错误码索引 |
muteAllRemoteAudioStreams | mute: bool | int | 错误码索引 |
muteAllRemoteVideoStreams | mute: bool | int | 错误码索引 |
muteLocalAudioStream | mute: bool | int | 错误码索引 |
muteLocalVideoStream | mute: bool | int | 错误码索引 |
muteRemoteAudioStream | uid: uid_t, mute: bool | int | 错误码索引 |
muteRemoteVideoStream | uid: uid_t, mute: bool | int | 错误码索引 |
renewToken | token: const char* | int | 错误码索引 |
setChannelProfile | profile: CHANNEL_PROFILE_TYPE | int | 错误码索引 |
setClientRole | role: CLIENT_ROLE_TYPE | int | 错误码索引 |
setLogFilter | filter: unsigned int | int | 错误码索引 |
setParameters | parameters: const char* | int | 错误码索引 |
setVideoEncoderConfiguration | config: const VideoEncoderConfiguration& | int | 错误码索引 |
setupLocalVideo | canvas: const VideoCanvas& | int | 错误码索引 |
setupRemoteVideo | canvas: const VideoCanvas& | int | 错误码索引 |
startPreview | — | int | 错误码索引 |
stopPreview | — | int | 错误码索引 |
switchCamera | — | int | 错误码索引 |
枚举
该端 SDK 没有独立枚举(Web SDK 用字符串联合类型表达)。
错误码常量
该端 SDK 未提供错误码常量(见“已知限制”)。平台 REST 错误码见 错误码全表,跨端 SDK 错误标识见 各端 SDK 错误标识。