Server Gateway SDK v3.7.200.21 for Linux Java
Server Gateway SDK v3.7.200.21 for Linux Java

Deployed on your server, the Agora Server Gateway SDK communicates with clients integrated with the Agora RTC SDK. You can use the Server Gateway SDK to transmit video and audio streams between the server and the client through SD-RTN™.

AgoraService

AgoraService is the entry point of the Agora Server Gateway SDK.

Method Description
AgoraService Creates an AgoraService object.
initialize Initializes the AgoraService object.
destroy Releases the AgoraService object.
agoraRtcConnCreate Creates an RTC connection object.
createCustomAudioTrackPcm Creates a local audio track object with the PCM data receiver.
createCustomAudioTrackEncoded Creates a local audio track object with the receiver for encoded audio data.
createMediaNodeFactory Creates a media node factory.
createCustomVideoTrackFrame Creates a local video track object with the custom video source.
createCustomVideoTrackEncoded Creates a local video track object with the receiver for encoded video data.

AgoraRtcConn

AgoraRtcConn allows an app to establish a connection to an Agora channel. In order to establish a connection, the app must provide an app ID, a token, and the ID of the channel that you want to join.

Method Description
connect Connects to an Agora RTC channel.
disconnect Disconnects from the Agora RTC channel.
startLastmileProbeTest Starts the last-mile network probe test.
stopLastmileProbeTest Stops the last-mile network probe test.
renewToken Renews the token.
getConnInfo Gets the current connection information.
getLocalUser Gets the ILocalUser object.
getUserInfo Gets the information of a specified user in the channel.
registerObserver Registers an IRtcConnObserver object.
unregisterObserver Releases the registered IRtcConnObserver object.
getConnId Gets the ID of the current connection.
enableEncryption Enables/Disables the built-in encryption.
getTransportStats Gets the transportation statistics of this connection.

Connecting to an Agora channel is done asynchronously, and apps can listen for the connection states of both the local and remote user using an RTC connection observer.

Event Description
onConnected Occurs when the connection state changes to STATE_CONNECTED.
onDisconnected Occurs when the connection state changes to STATE_DISCONNECTED.
onReconnecting Occurs when the connection state changes to STATE_RECONNECTING.
onConnectionLost Occurs when the SDK loses connection with the Agora channel.
onLastmileQuality Reports the quality of the last mile network.
onLastmileProbeResult Reports the last-mile network probe result.
onTokenPrivilegeWillExpire Occurs when the token privilege expires in 30 seconds.
onTokenPrivilegeDidExpire Occurs when the token privilege has expired.
onConnectionFailure Occurs when the connection state changes to STATE_FAILED.
onUserJoined Occurs when a remote user has successfully joined the channel.
onUserLeft Occurs when a remote user has left the channel.
onTransportStats Reports the transport statistics of the current connection,
onChangeRoleSuccess Occurs when the role of the local user changes.
onChangeRoleFailure Occurs when the role of the local user changes.
onUserNetworkQuality Reports the network quality of each user.

Local user

Once connected, each RTC connection has its own local user. Apps can get the local user object using getLocalUser.

Each local user has two user roles: broadcaster (publisher or subscriber) and audience (subscriber only). The publisher publishes audio and video tracks, while the audience receives them.

Method Description
setUserRole Sets the role of the user.
getUserRole Gets the role of the user.
setAudioEncoderConfig Configures the audio encoder.
publishAudio Publishes a local audio track to the RTC connection.
unpublishAudio Stops publishing the local audio track to the RTC connection.
publishVideo Publishes a local video track to the RTC connection.
unpublishVideo Stops publishing the local video track to the RTC connection.
subscribeAudio Subscribes to the audio of a specified remote user in the RTC connection.
subscribeAllAudio Subscribes to the audio of all remote users in the RTC connection.
unsubscribeAudio Stops subscribing to the audio of a specified remote user in the RTC connection.
unsubscribeAllAudio Stops subscribing to the audio of all remote users in the RTC connection.
setPlaybackAudioFrameBeforeMixingParameters Sets the audio frame parameters for the onPlaybackAudioFrameBeforeMixing callback.
registerAudioFrameObserver Registers an audio frame observer object.
unregisterAudioFrameObserver Releases the audio frame observer object.
subscribeVideo Subscribes to the video of a specified remote user in the RTC connection.
subscribeAllVideo Subscribes to the video of all remote users in the RTC connection.
unsubscribeVideo Stops subscribing to the video of a specified remote user in the RTC connection.
unsubscribeAllVideo Stops subscribing to the video of all remote users in the RTC connection.
registerObserver Registers a local user observer object.
unregisterObserver Releases the local user observer object.
Event Description
onAudioTrackPublishSuccess Occurs when the local audio track has published.
onLocalAudioTrackStateChanged Occurs when the state of the local audio track changes.
onLocalAudioTrackStatistics Reports the statistics of the local audio track.
onRemoteAudioTrackStatistics Reports the statistics of the remote audio track.
onUserAudioTrackSubscribed Occurs when the first remote audio frame is received.
onUserAudioTrackStateChanged Occurs when the state of a remote audio track changes.
onVideoTrackPublishSuccess Occurs when the local video track is published.
onLocalVideoTrackStateChanged Occurs when the state of the local video track changes.
onLocalVideoTrackStatistics Reports the statistics of the local video track.
onUserVideoTrackSubscribed Occurs when the first remote video frame is received.
onUserVideoTrackStateChanged Occurs when the state of a remote video track changes.
onRemoteVideoTrackStatistics Reports the statistics of the remote video track.

Local audio track

A local audio track can be created by createCustomAudioTrackPcm or createCustomAudioTrackEncoded.

After the local audio track is created, you can publish one or multiple local audio tracks using publishAudio.

Method Description
setEnabled Enables or disables the local audio track.
isEnabled Gets whether the local audio track is enabled.
getState Gets the state of the local audio.
getStats Gets the statistics of the local audio track.
adjustPublishVolume Adjusts the audio volume for publishing.
getPublishVolume Gets the current volume for publishing.

Remote audio track

Method Description
getStatistics Gets the statistics of the remote audio track.
getState Gets the state of the remote audio.

Local video track

A local video track can be created by createCustomVideoTrackFrame or createCustomVideoTrackEncoded.

It originates from one video source, for example, the camera capturer, the screen capturer, or a custom video source.

You can publish one or multiple local video tracks through AgoraLocalUser.publishVideo. Each video track has its own video stream.

Method Description
setEnabled Enables or disables the local video track.
setVideoEncoderConfig Sets the video encoder configuration.
getState Gets the state of the local video.
getStatistics Gets the statistics of the remote video track.

Remote video track

Method Description
getState Gets the state of the remote video.
getTrackInfo Gets the information of the remote video track.
registerVideoEncodedImageReceiver Registers an AgoraVideoEncodedImageReceiver object.
unregisterVideoEncodedImageReceiver Releases the AgoraVideoEncodedImageReceiver object.

Media node factory

Use this factory to create audio and video nodes for the audio and video tracks.

Method Description
createAudioPcmDataSender Creates a PCM audio data sender.
createAudioEncodedFrameSender Creates an encoded audio data sender.
createVideoFrameSender Creates a YUV video frame sender.
createVideoEncodedImageSender Creates an encoded video image sender.

Audio data sender

Method Description
AgoraAudioPcmDataSender.send Sends the PCM audio data to the local audio track.
AgoraAudioEncodedFrameSender.send Sends the encoded audio data to the local audio track.

Video data sender

Method Description
AgoraVideoFrameSender.send Sends the YUV video frame to the video track.
AgoraVideoEncodedImageSender.send Sends the encoded video image to the video track.