IoT SDK for Android v1.8.0
Classes | Public Member Functions | List of all members
io.agora.rtc.AgoraRtcService Class Reference

Classes

class  AreaCode
 
class  AudioCodecOption
 
class  AudioCodecType
 
class  AudioDataType
 
class  AudioFrameInfo
 
class  ChannelOptions
 
class  CloudProxyType
 
class  ConnectionIdSpecial
 
class  ConnectionInfo
 
class  ErrorCode
 
class  LogConfig
 
class  LogLevel
 
class  NetworkEventType
 
class  RtcServiceOptions
 
class  RtmErrCode
 
class  UserOfflineReason
 
class  VideoDataType
 
class  VideoFrameInfo
 
class  VideoFrameRate
 
class  VideoFrameType
 
class  VideoStreamType
 

Public Member Functions

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)
 

Detailed Description

The AgoraRtcService class.

Member Function Documentation

◆ configLog()

native int io.agora.rtc.AgoraRtcService.configLog ( int  sizePerFile,
int  maxFileCount 
)

Configures the log file.

Parameters
sizePerFileThe size (bytes) of each log file. The value range is [0, 10*1024*1024 (10 MB)] and the default value is 1*1024*1024 (1 MB). Set this parameter to 0 to disable logs.
maxFileCountThe maximum number of log file numbers. The value range is [0, 100] and the default value is 10. Set this parameter to 0 to disable logs.
Returns
  • 0: Success.
  • <0: Failure.

◆ createConnection()

native int io.agora.rtc.AgoraRtcService.createConnection ( )

Creates a connection.

Returns
Connection ID. A connection can correspond to multiple RTC channels.

◆ destroyConnection()

native int io.agora.rtc.AgoraRtcService.destroyConnection ( int  connId)

Destroys a connection.

Parameters
connIdConnection ID. A connection can correspond to multiple RTC channels. Use createConnection to create a connection. Set this parameter to CONNECTION_ID_ALL to specify all current connections.
Returns
  • 0: Success.
  • <0: Failure.

◆ errToStr()

native String io.agora.rtc.AgoraRtcService.errToStr ( int  err)

Converts an error code to a string.

Note
You do not have to release the string after use.
Parameters
errThe error code.
Returns
The string.

◆ fini()

native int io.agora.rtc.AgoraRtcService.fini ( )

Releases all resources allocated to the SDK by init.

Returns
  • 0: Success.
  • <0: Failure.

◆ getConnectionInfo()

native int io.agora.rtc.AgoraRtcService.getConnectionInfo ( int  connId,
ConnectionInfo  connInfo 
)

Gets information about a connection.

Parameters
connIdConnection ID. A connection can correspond to multiple RTC channels. Use createConnection to create a connection.
connInfoConnection information. See ConnectionInfo.
Returns
  • 0: Success.
  • <0: Failure.

◆ getVersion()

native String io.agora.rtc.AgoraRtcService.getVersion ( )

Gets the SDK version.

Returns
The SDK version.

◆ init()

native int io.agora.rtc.AgoraRtcService.init ( String  appId,
AgoraRtcEvents  events,
RtcServiceOptions  options 
)

Initializes the SDK.

Note
  • In each process, you can only initialize the SDK once.
  • Each time you initialize the SDK, the SDK creates a new folder in your specified log location to save the log files. Agora recommends that you clean the log folder each time you initialize the SDK.
Parameters
appIdAgora App ID.
eventsA set of callbacks that handles SDK events.
optionsService options.
Returns
  • 0: Success.
  • <0: Failure.

◆ joinChannel()

native int io.agora.rtc.AgoraRtcService.joinChannel ( int  connId,
String  channelName,
int  uid,
String  token,
ChannelOptions  options 
)

Joins an RTC channel corresponding to a specified connection.

Parameters
connIdConnection ID. A connection can correspond to multiple RTC channels. Use createConnection to create a connection. Set this parameter to CONNECTION_ID_ALL to specify all current connections.
channelNameChannel name. The length of a channel name must be less than 64 bytes. Supported character scopes are:
  • The 26 lowercase English letters: a to z
  • The 26 uppercase English letters: A to Z
  • The 10 numbers: 0 to 9
  • The space
  • "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", " {", "}", "|", "~", ","
uidUser ID, which is a 32-bit unsigned integer with a value ranging from 1 to 2^32-1. The uid must be unique. If a uid is set to 0, the SDK assigns and returns a non-zero uid in the on_join_channel_success callback. You must save the returned uid.
tokenRTC Token for authentication.
  • If you enable App ID authentication in your Agora project, set this parameter to NULL.
  • If you enable App ID + Token authentication in your Agora project, set this parameter to the RTC token generated on your app server.
optionsRTC channel options.
Returns
  • 0: Success.
  • <0: Failure.

◆ leaveChannel()

native int io.agora.rtc.AgoraRtcService.leaveChannel ( int  connId)

Leaves an RTC channel corresponding to a specified connection.

Parameters
connIdConnection ID. A connection can correspond to multiple RTC channels. Use createConnection to create a connection. Set this parameter to CONNECTION_ID_ALL to specify all current connections.
Returns
  • 0: Success.
  • <0: Failure.

◆ licenseGenCredential()

native String io.agora.rtc.AgoraRtcService.licenseGenCredential ( )

Generates a credential, which is a unique device identifier.

Returns
Credential buffer holding the generated data.

◆ licenseVerify()

native int io.agora.rtc.AgoraRtcService.licenseVerify ( String  certificate,
String  credential 
)

Authenticates the SDK license.

Note
Call this method before calling init.
Parameters
certificateCertificate buffer.
credentialCredential buffer.
Returns
  • = 0: Success.
  • < 0: Failure.

◆ loginRtm()

native int io.agora.rtc.AgoraRtcService.loginRtm ( String  rtmUid,
String  rtmToken,
AgoraRtmEvents  events 
)

Logs into RTM.

Parameters
rtmUidRTM user ID. Length should be less than 64 bytes. Supported characters include:
  • The 26 lowercase English letters: a to z
  • The 26 uppercase English letters: A to Z
  • The 10 numbers: 0 to 9
  • The space
  • "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", " {", "}", "|", "~", ","
rtmTokenRTM Token for authentication.
  • If you enable App ID authentication in your Agora project, set this parameter to NULL.
  • If you enable App ID + Token authentication in your Agora project, set this parameter to the RTM token generated on your app server.
eventsRTM event handler.
Returns
  • 0: Success.
  • <0: Failure.

◆ logoutRtm()

native int io.agora.rtc.AgoraRtcService.logoutRtm ( )

Logs out of RTM.

Returns
  • 0: Success.
  • <0: Failure.

◆ muteLocalAudio()

native int io.agora.rtc.AgoraRtcService.muteLocalAudio ( int  connId,
boolean  mute 
)

Enables/disables sending local audio data to one or multiple channels corresponding to a connection.

Parameters
connIdConnection ID. A connection can correspond to multiple RTC channels. Use createConnection to create a connection. Set this parameter to CONNECTION_ID_ALL to specify all current connections.
muteEnables/disables sending local audio data:
  • true: Disable.
  • false: Enable.
Returns
  • 0: Success.
  • <0: Failure.

◆ muteLocalVideo()

native int io.agora.rtc.AgoraRtcService.muteLocalVideo ( int  connId,
boolean  mute 
)

Enables/disables sending local video data to one or multiple channels corresponding to a connection.

Parameters
connIdConnection ID. A connection can correspond to multiple RTC channels. Use createConnection to create a connection. Set this parameter to CONNECTION_ID_ALL to specify all current connections.
muteEnables/disables sending local video data:
  • true: Disable.
  • false: Enable.
Returns
  • 0: Success.
  • <0: Failure.

◆ muteRemoteAudio()

native int io.agora.rtc.AgoraRtcService.muteRemoteAudio ( int  connId,
int  remoteUid,
boolean  mute 
)

Enables/disables receiving remote audio data from one or multiple channels corresponding to a connection.

Parameters
connIdConnection ID. A connection can correspond to multiple RTC channels. Use createConnection to create a connection. Set this parameter to CONNECTION_ID_ALL to specify all current connections.
remoteUidRemote user ID. Set this parameter to 0 to specify all remote users.
muteEnables/disables receiving remote audio data:
  • true: Disable.
  • false: Enable.
Returns
  • 0: Success.
  • <0: Failure.

◆ muteRemoteVideo()

native int io.agora.rtc.AgoraRtcService.muteRemoteVideo ( int  connId,
int  uid,
boolean  mute 
)

Enables/disables receiving remote video data from one or multiple channels corresponding to a connection.

Parameters
connIdConnection ID. A connection can correspond to multiple RTC channels. Use createConnection to create a connection. Set this parameter to CONNECTION_ID_ALL to specify all current connections.
uidRemote user ID. Set this parameter to 0 to specify all remote users.
muteEnables/disables receiving remote video data:
  • true: Disable.
  • false: Enable.
Returns
  • 0: Success.
  • <0: Failure.

◆ notifyNetworkEvent()

native int io.agora.rtc.AgoraRtcService.notifyNetworkEvent ( int  event)

Sets the network state.

Parameters
eventNetwork event type. See NetworkEventType.
Returns
  • 0: Success.
  • <0: Failure.

◆ renewToken()

native int io.agora.rtc.AgoraRtcService.renewToken ( int  connId,
String  token 
)

Renews an RTC token for one or multiple channels corresponding to a connection.

Parameters
connIdConnection ID. A connection can correspond to multiple RTC channels. Use createConnection to create a connection. Set this parameter to CONNECTION_ID_ALL to specify all current connections.
tokenToken for authentication.
Returns
  • 0: Success.
  • <0: Failure.

◆ requestVideoKeyFrame()

native int io.agora.rtc.AgoraRtcService.requestVideoKeyFrame ( int  connId,
int  remoteUid,
int  streamType 
)

Requests a keyframe from a remote user in one or multiple channels corresponding to a connection.

Parameters
connIdConnection ID. A connection can correspond to multiple RTC channels. Use createConnection to create a connection. Set this parameter to CONNECTION_ID_ALL to specify all current connections.
remoteUidRemote user ID. Set this parameter to 0 to specify all remote users.
streamTypeStream type.
Returns
  • 0: Success.
  • <0: Failure.

◆ sendAudioData()

native int io.agora.rtc.AgoraRtcService.sendAudioData ( int  connId,
byte[]  data,
AudioFrameInfo  info 
)

Sends an audio frame to one or multiple channels corresponding to a connection.

Parameters
connIdConnection ID. A connection can correspond to multiple RTC channels. Use createConnection to create a connection. Set this parameter to CONNECTION_ID_ALL to specify all current connections.
dataAudio frame buffer.
infoAudio frame information.
Returns
  • 0: Success.
  • <0: Failure.

◆ sendRtm()

native int io.agora.rtc.AgoraRtcService.sendRtm ( String  rtmUid,
int  messageId,
byte[]  message 
)

Sends an RTM message.

Note
You must log into RTM and receive the on_rtm_event callback before sending RTM message. The call frequency of this method must not exceed 180 within 3 seconds.
Parameters
rtmUidRTM user ID.
messageIdMessage ID.
messageMessage content. Only supports UTF-8 encoding.
Returns
:
  • 0: Success.
  • <0: Failure.

◆ sendVideoData()

native int io.agora.rtc.AgoraRtcService.sendVideoData ( int  connId,
byte[]  data,
VideoFrameInfo  info 
)

Sends a video frame to one or multiple channels corresponding to a connection.

Parameters
connIdConnection ID. A connection can correspond to multiple RTC channels. Use createConnection to create a connection. Set this parameter to CONNECTION_ID_ALL to specify all current connections.
dataAudio frame buffer.
infoAudio frame information.
Returns
  • 0: Success.
  • <0: Failure.

◆ setBweParam()

native int io.agora.rtc.AgoraRtcService.setBweParam ( int  connId,
int  miniBps,
int  maxBps,
int  startBps 
)

Sets network bandwidth estimation (BWE) parameters.

Parameters
connIdConnection ID. A connection can correspond to multiple RTC channels. Use createConnection to create a connection. Set this parameter to CONNECTION_ID_ALL to specify all current connections.
miniBpsMinimal bitrate (bps).
maxBpsMaximum bitrate (bps).
startBpsStarting bitrate (bps).
Returns
:
  • 0: Success.
  • <0: Failure.

◆ setCloudProxy()

native int io.agora.rtc.AgoraRtcService.setCloudProxy ( int  type)

Sets cloud proxy.

Parameters
typeSets the type of cloud proxy.
Returns
:
  • 0: Success.
  • <0: Failure.

◆ setLogLevel()

native int io.agora.rtc.AgoraRtcService.setLogLevel ( int  level)

Sets the log level.

Parameters
levelLog level. See LogLevel.
Returns
  • 0: Success.
  • <0: Failure.

◆ setParams()

native int io.agora.rtc.AgoraRtcService.setParams ( String  params)

Provides technical preview functionalities or special customizations by configuring the SDK with JSON options.

The JSON options are not public by default. Agora is working on making commonly used JSON options public in a standard way.

Parameters
paramsSets the parameter as a JSON string in the specified format.
Returns
:
  • 0: Success.
  • <0: Failure.

The documentation for this class was generated from the following file: