Cocos2d-x SDK API Reference
Complete Cocos2d-x public surface generated from the public SDK interface definition: classes, interfaces, enums, events, error identifiers and capability scope.
Interface overview
This page lists the public API of Cocos2d-x(C++ binding): classes, methods, overloads, properties, events and error codes. The interface definition matches the SDK package version.
| Checklist item | Count |
|---|---|
| Interface / class | 2 |
| Method | 43 |
| Method overloads | 48 |
| Property | 0 |
| Enums | 0 |
| error-code constants | 0 |
Availability
This platform's SDK: Generally available. The interface definition matches the SDK package version; runtime capability follows the published SDK package.
Join channel flow
Arranged in the typical call order of join / leave / publish / subscribe; the parameter table is expanded under “Parameters of the minimal runnable flow”.
| Step | Interface | Method | Overload count |
|---|---|---|---|
| enable video and preview | NimeetCocos2dxRtcEngine | enableVideo | 1 |
| Create / initialize | NimeetCocos2dxRtcEngine | initialize | 1 |
| Join a channel | NimeetCocos2dxRtcEngine | joinChannel | 2 |
| Leave a channel | NimeetCocos2dxRtcEngine | leaveChannel | 2 |
| subscribe to remote media | NimeetCocos2dxRtcEngine | muteRemoteAudioStream | 1 |
| Renew the Token | NimeetCocos2dxRtcEngine | renewToken | 1 |
| Channel scenarios | NimeetCocos2dxRtcEngine | setChannelProfile | 1 |
| role switching | NimeetCocos2dxRtcEngine | setClientRole | 2 |
| local video | NimeetCocos2dxRtcEngine | setupLocalVideo | 1 |
parameters for the minimal runnable flow
| Parameters | Type | Optional | Variadic parameters |
|---|---|---|---|
context | const RtcEngineContext& | No | No |
token | const char* | No | No |
channelId | const char* | No | No |
info | const char* | No | No |
uid | uid_t | No | No |
token | const char* | No | No |
channelId | const char* | No | No |
uid | uid_t | No | No |
options | const ChannelMediaOptions& | No | No |
options | const LeaveChannelOptions& | No | No |
uid | uid_t | No | No |
mute | bool | No | No |
token | const char* | No | No |
profile | CHANNEL_PROFILE_TYPE | No | No |
role | CLIENT_ROLE_TYPE | No | No |
role | CLIENT_ROLE_TYPE | No | No |
options | const ClientRoleOptions& | No | No |
canvas | const VideoCanvas& | No | No |
Endpoint index
| Interface | Method | Property | Events |
|---|---|---|---|
IRtcEngineEventHandler | 14 | 0 | 0 |
NimeetCocos2dxRtcEngine | 29 | 0 | 0 |
all endpoints
IRtcEngineEventHandler 14 method / 0 Property
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): voidMethod detail: 14 / 14 (parameters, returns, errors)
| Method | Parameters | Returns | Errors |
|---|---|---|---|
onAudioVolumeIndication | speakers: const AudioVolumeInfo*, speakerNumber: unsigned int, totalVolume: int | void | Error code index |
onConnectionStateChanged | state: CONNECTION_STATE_TYPE, reason: CONNECTION_CHANGED_REASON_TYPE | void | Error code index |
onError | err: int, msg: const char* | void | Error code index |
onJoinChannelSuccess | channel: const char*, uid: uid_t, elapsed: int | void | Error code index |
onLeaveChannel | stats: const RtcStats& | void | Error code index |
onLocalAudioStateChanged | state: LOCAL_AUDIO_STREAM_STATE, reason: LOCAL_AUDIO_STREAM_REASON | void | Error code index |
onLocalVideoStateChanged | source: VIDEO_SOURCE_TYPE, state: LOCAL_VIDEO_STREAM_STATE, reason: LOCAL_VIDEO_STREAM_REASON | void | Error code index |
onRejoinChannelSuccess | channel: const char*, uid: uid_t, elapsed: int | void | Error code index |
onRemoteAudioStateChanged | uid: uid_t, state: REMOTE_AUDIO_STATE, reason: REMOTE_AUDIO_STATE_REASON, elapsed: int | void | Error code index |
onRemoteVideoStateChanged | uid: uid_t, state: REMOTE_VIDEO_STATE, reason: REMOTE_VIDEO_STATE_REASON, elapsed: int | void | Error code index |
onRequestToken | — | void | Error code index |
onRtcStats | stats: const RtcStats& | void | Error code index |
onUserJoined | uid: uid_t, elapsed: int | void | Error code index |
onUserOffline | uid: uid_t, reason: USER_OFFLINE_REASON_TYPE | void | Error code index |
NimeetCocos2dxRtcEngine 29 method / 0 Property
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(): intMethod detail: 29 / 29 (parameters, returns, errors)
| Method | Parameters | Returns | Errors |
|---|---|---|---|
adjustPlaybackSignalVolume | volume: int | int | Error code index |
adjustRecordingSignalVolume | volume: int | int | Error code index |
disableAudio | — | int | Error code index |
disableVideo | — | int | Error code index |
enableAudio | — | int | Error code index |
enableAudioVolumeIndication | interval: int, smooth: int, reportVad: bool | int | Error code index |
enableLocalAudio | enabled: bool | int | Error code index |
enableLocalVideo | enabled: bool | int | Error code index |
enableVideo | — | int | Error code index |
initialize | context: const RtcEngineContext& | int | Error code index |
joinChannel | token: const char*, channelId: const char*, info: const char*, uid: uid_t | int | Error code index |
leaveChannel | — | int | Error code index |
muteAllRemoteAudioStreams | mute: bool | int | Error code index |
muteAllRemoteVideoStreams | mute: bool | int | Error code index |
muteLocalAudioStream | mute: bool | int | Error code index |
muteLocalVideoStream | mute: bool | int | Error code index |
muteRemoteAudioStream | uid: uid_t, mute: bool | int | Error code index |
muteRemoteVideoStream | uid: uid_t, mute: bool | int | Error code index |
renewToken | token: const char* | int | Error code index |
setChannelProfile | profile: CHANNEL_PROFILE_TYPE | int | Error code index |
setClientRole | role: CLIENT_ROLE_TYPE | int | Error code index |
setLogFilter | filter: unsigned int | int | Error code index |
setParameters | parameters: const char* | int | Error code index |
setVideoEncoderConfiguration | config: const VideoEncoderConfiguration& | int | Error code index |
setupLocalVideo | canvas: const VideoCanvas& | int | Error code index |
setupRemoteVideo | canvas: const VideoCanvas& | int | Error code index |
startPreview | — | int | Error code index |
stopPreview | — | int | Error code index |
switchCamera | — | int | Error code index |
Enums
This SDK has no standalone enums (the Web SDK expresses them as string union types).
error-code constants
This SDK does not expose error-code constants (see Known limitations). For platform REST error codes see Error codes; for cross-platform SDK error identifiers see SDK error identifiers.