|
Agora C++ API Reference for All Platforms
|
#include <NGIAgoraRtcConnection.h>
Inherits agora::RefCountInterface.
Inherited by agora::rtc::IRtcConnectionEx.
Public Member Functions | |
| virtual int | connect (const char *token, const char *channelId, const char *info, user_id_t userId, aosl_ref_t ares=AOSL_REF_INVALID)=0 |
| virtual int | connect (const TConnectSettings &settings, aosl_ref_t ares=AOSL_REF_INVALID)=0 |
| virtual int | disconnect (aosl_ref_t ares=AOSL_REF_INVALID)=0 |
| virtual int | startLastmileProbeTest (const LastmileProbeConfig &config, aosl_ref_t ares=AOSL_REF_INVALID)=0 |
| virtual int | stopLastmileProbeTest (aosl_ref_t ares=AOSL_REF_INVALID)=0 |
| virtual int | renewToken (const char *token, aosl_ref_t ares=AOSL_REF_INVALID)=0 |
| virtual TConnectionInfo | getConnectionInfo ()=0 |
| virtual ILocalUser * | getLocalUser ()=0 |
| virtual int | getRemoteUsers (UserList &users)=0 |
| virtual int | getUserInfo (user_id_t userId, agora::UserInfo &userInfo)=0 |
| virtual int | registerObserver (IRtcConnectionObserver *observer, void(*safeDeleter)(IRtcConnectionObserver *)=NULL, aosl_ref_t ares=AOSL_REF_INVALID)=0 |
| virtual int | unregisterObserver (IRtcConnectionObserver *observer)=0 |
| virtual int | registerNetworkObserver (INetworkObserver *observer, void(*safeDeleter)(INetworkObserver *)=NULL, aosl_ref_t ares=AOSL_REF_INVALID)=0 |
| virtual int | unregisterNetworkObserver (INetworkObserver *observer)=0 |
| virtual conn_id_t | getConnId ()=0 |
| virtual RtcStats | getTransportStats ()=0 |
| virtual agora::base::IAgoraParameter * | getAgoraParameter ()=0 |
| virtual int | createDataStream (int *streamId, bool reliable, bool ordered, bool sync)=0 |
| virtual int | sendStreamMessage (int streamId, const char *data, size_t length, aosl_ref_t ares=AOSL_REF_INVALID)=0 |
| virtual int | sendRdtMessage (user_id_t userId, RdtStreamType type, const char *data, size_t length, aosl_ref_t ares=AOSL_REF_INVALID)=0 |
| virtual int | sendMediaControlMessage (user_id_t userId, const char *data, size_t length, aosl_ref_t ares=AOSL_REF_INVALID)=0 |
| virtual int | enableEncryption (bool enabled, const EncryptionConfig &config, aosl_ref_t ares=AOSL_REF_INVALID)=0 |
| virtual int | sendCustomReportMessage (const char *id, const char *category, const char *event, const char *label, int value, aosl_ref_t ares=AOSL_REF_INVALID)=0 |
| virtual int | getUserInfoByUserAccount (const char *userAccount, rtc::UserInfo *userInfo)=0 |
| virtual int | getUserInfoByUid (uid_t uid, rtc::UserInfo *userInfo)=0 |
| virtual int | enableMultipath (bool enable, aosl_ref_t ares=AOSL_REF_INVALID)=0 |
| virtual int | setUplinkMultipathMode (MultipathMode mode, aosl_ref_t ares=AOSL_REF_INVALID)=0 |
| virtual int | setDownlinkMultipathMode (MultipathMode mode, aosl_ref_t ares=AOSL_REF_INVALID)=0 |
| virtual int | setPreferMultipathType (MultipathType type, aosl_ref_t ares=AOSL_REF_INVALID)=0 |
Public Member Functions inherited from agora::RefCountInterface | |
| virtual void | AddRef () const =0 |
| virtual RefCountReleaseStatus | Release () const =0 |
| virtual bool | HasOneRef () const =0 |
Protected Member Functions | |
| ~IRtcConnection () | |
Protected Member Functions inherited from agora::RefCountInterface | |
| virtual | ~RefCountInterface () |
The IRtcConnection class.
You can use this class for managing the connection between your app and an Agora Channel.
Once connected, your app gets an AgoraLocalUser object for publishing and subscribing to media streams in the Agora Channel.
Connecting to a channel is done asynchronously, and your app can listen for the connection states or events through IRtcConnectionObserver. IRtcConnection also monitors remote users in the channel. The SDK notifies your app when a remote user joins or leaves the channel.
|
inlineprotected |
|
pure virtual |
Connects to an Agora channel.
When the method call succeeds, the connection state changes from CONNECTION_STATE_DISCONNECTED(1) to CONNECTION_STATE_CONNECTING(2).
Depending on the whether the connection succeeds or not, the connection state changes to either CONNECTION_STATE_CONNECTED(3) or CONNECTION_STATE_FAILED(5). The SDK also triggers onConnected or onDisconnected to notify you of the state change.
| token | The app ID. |
| channelId | The channel name. It must be in the string format and not exceed 64 bytes in length. Supported character scopes are:
|
| userId | The ID of the local user. If you do not specify a user ID or set userId as null, the SDK returns a user ID in the onConnected callback. Your app must record and maintain the userId since the SDK does not do so. |
|
pure virtual |
Connects to an Agora channel.
When the method call succeeds, the connection state changes from CONNECTION_STATE_DISCONNECTED(1) to CONNECTION_STATE_CONNECTING(2).
Depending on the whether the connection succeeds or not, the connection state changes to either CONNECTION_STATE_CONNECTED(3) or CONNECTION_STATE_FAILED(5). The SDK also triggers onConnected or onDisconnected to notify you of the state change.
| settings | The settings of connecting. |
|
pure virtual |
Disconnects from the Agora channel.
Once your app successful disconnects from the channel, the connection state changes to CONNECTION_STATE_DISCONNECTED(1). You are also notified with the callback onDisconnected.
|
pure virtual |
Starts the last-mile network probe test.
Call this method before connecting to the channel to get the uplink and downlink last-mile network statistics, including the bandwidth, packet loss, jitter, and round-trip time (RTT).
After you enable the last-mile network probe test, the SDK triggers the following callbacks:
| config | The configurations of the last-mile network probe test. See LastmileProbeConfig. |
|
pure virtual |
Stops the last-mile network probe test.
|
pure virtual |
Renews the token.
The token expires after a certain period of time. The SDK triggers the onRenewTokenResult callback after the token is renewed.
When the onError callback reports ERR_TOKEN_EXPIRED(109), you must generate a new token from the server and then call this method to renew it. Otherwise, the SDK disconnects from the Agora channel.
| token | The pointer to the new token. |
|
pure virtual |
Gets the connection information.
|
pure virtual |
Gets the ILocalUser object.
|
pure virtual |
Gets the information of all the remote users in the channel.
After a user successfully connects to the channel, you can also get the information of this remote user with the onUserJoined callback.
| [out] | users | The reference to the UserList object, which contains the information of all users in the channel. |
|
pure virtual |
Gets the information of a specified remote user in the channel.
| [in] | userId | ID of the user whose information you want to get. |
| [out] | userInfo | The reference to the UserInfo object, which contains the information of the specified user. |
|
pure virtual |
Registers an RTC connection observer. You can call this method only after creating an IRtcConnection object.
| observer | The pointer to the IRtcConnectionObserver object. |
|
pure virtual |
Releases the registered IRtcConnectionObserver object.
| observer | The pointer to the IRtcConnectionObserver object created by the registerObserver method. |
|
pure virtual |
Registers an network observer object.
| observer | The pointer to the INetworkObserver object. |
|
pure virtual |
Releases the registered INetworkObserver object.
| observer | The pointer to the INetworkObserver object created by the registerNetworkObserver method. |
|
pure virtual |
Gets the ID of the connection.
|
pure virtual |
Gets the transportation statistics of the RTC connection.
|
pure virtual |
Gets the IAgoraParameter object.
Implemented in agora::rtc::IRtcConnectionEx.
|
pure virtual |
Creates a data stream.
Each user can create up to five data streams during the lifecycle of an RTC connection.
reliable and ordered parameters as true or false. Do not set one as true and the other as false.| streamId | The pointer to the ID of the data stream. |
| reliable | Whether to guarantee the receivers receive the data stream within five seconds:
|
| ordered | Whether the receivers receive the data stream in the order of sending:
|
|
pure virtual |
Sends data stream messages to all users in a channel.
| streamId | The ID of the sent data stream, returned in the createDataStream method. |
| data | The pointer to the sent data. |
| length | The length of the sent data. |
|
pure virtual |
Send Reliable message to remote uid in channel.
| UserId | remote user id. |
| type | Reliable Data Transmission tunnel message type. |
| data | The pointer to the sent data. |
| length | The length of the sent data. |
|
pure virtual |
Send Media Control Message to remote uid in channel.
| userId | ID of the user who sends the data. |
| data | The sending data. |
| length | The length (byte) of the data. |
|
pure virtual |
Enables/Disables the built-in encryption.
In scenarios requiring high security, Agora recommends calling this method to enable the built-in encryption before joining a channel.
All users in the same channel must use the same encryption mode and encryption key. Once all users leave the channel, the encryption key of this channel is automatically cleared.
| enabled | Whether to enable the built-in encryption:
|
| config | Configurations of built-in encryption schemas. See EncryptionConfig. |
|
pure virtual |
Reports a custom event to Agora.
| id | The custom event ID. |
| category | The category of the custom event. |
| event | The custom event to report. |
| label | The label of the custom event. |
| value | The value of the custom event. |
|
pure virtual |
Gets the user information by user account, which is in string format.
| userAccount | The user account of the user. | |
| [in,out] | userInfo | A UserInfo object that identifies the user:
|
|
pure virtual |
Gets the user information by user ID, which is in integer format.
| uid | The ID of the remote user. | |
| [in,out] | userInfo | A UserInfo object that identifies the user:
|
|
pure virtual |
Enables or disables the multipath feature.
When enabled, the SDK can use multiple network paths for data transmission, which can improve the reliability and performance of the connection.
| enable | A boolean value indicating whether to enable (true) or disable (false) multipath. |
| ares | A reference for asynchronous operations, defaulting to AOSL_REF_INVALID. |
|
pure virtual |
Sets the uplink multipath mode.
This method allows the user to specify the mode for uplink multipath transmission. Different modes may optimize for latency, bandwidth, or reliability.
| mode | The desired uplink multipath mode. |
| ares | A reference for asynchronous operations, defaulting to AOSL_REF_INVALID. |
|
pure virtual |
Sets the downlink multipath mode.
This method allows the user to specify the mode for downlink multipath transmission. Different modes may optimize for latency, bandwidth, or reliability.
| mode | The desired downlink multipath mode. |
| ares | A reference for asynchronous operations, defaulting to AOSL_REF_INVALID. |
|
pure virtual |
Sets the preferred multipath type.
This method allows the user to specify the preferred type of multipath transmission. The type may influence how the SDK manages network resources for optimal performance.
| type | The preferred multipath type. |
| ares | A reference for asynchronous operations, defaulting to AOSL_REF_INVALID. |