Server Gateway SDK v3.7.200.21 for Linux Java
Public Member Functions | List of all members
io.agora.rtc.AgoraLocalUser Class Reference

Public Member Functions

 AgoraLocalUser (long cptr)
 
native void setUserRole (int role)
 
native int getUserRole ()
 
native int setAudioEncoderConfig (AudioEncoderConfig config)
 
native int publishAudio (AgoraLocalAudioTrack agora_local_audio_track)
 
native int unpublishAudio (AgoraLocalAudioTrack agora_local_audio_track)
 
native int publishVideo (AgoraLocalVideoTrack agora_local_video_track)
 
native int unpublishVideo (AgoraLocalVideoTrack agora_local_video_track)
 
native int subscribeAudio (String user_id)
 
native int subscribeAllAudio ()
 
native int unsubscribeAudio (String user_id)
 
native int unsubscribeAllAudio ()
 
native int setPlaybackAudioFrameParameters (int channels, int sample_rate_hz, int mode, int samples_per_call)
 
native int setRecordingAudioFrameParameters (int channels, int sample_rate_hz, int mode, int samples_per_call)
 
native int setMixedAudioFrameParameters (int channels, int sample_rate_hz, int mode, int samples_per_call)
 
native int setPlaybackAudioFrameBeforeMixingParameters (int channels, int sample_rate_hz, int mode, int samples_per_call)
 
native int registerAudioFrameObserver (IAudioFrameObserver observer)
 
native int unregisterAudioFrameObserver ()
 
native int subscribeVideo (String user_id, VideoSubscriptionOptions options)
 
native int subscribeAllVideo (VideoSubscriptionOptions options)
 
native int unsubscribeVideo (String user_id)
 
native int unsubscribeAllVideo ()
 
native int setAudioVolumeIndicationParameters (int interval_in_ms, int smooth, boolean report_vad)
 
native int registerObserver (ILocalUserObserver observer)
 
native int unregisterObserver ()
 
native int sendIntraRequest (String uid)
 

Constructor & Destructor Documentation

◆ AgoraLocalUser()

io.agora.rtc.AgoraLocalUser.AgoraLocalUser ( long  cptr)

Constructor.

Member Function Documentation

◆ getUserRole()

native int io.agora.rtc.AgoraLocalUser.getUserRole ( )

Gets the role of the user.

Returns
The role of the user.

◆ publishAudio()

native int io.agora.rtc.AgoraLocalUser.publishAudio ( AgoraLocalAudioTrack  agora_local_audio_track)

Publishes a local audio track to the channel.

By default, all published audio tracks are mixed.

Parameters
agora_local_audio_trackThe local audio track to be published.
Returns
  • 0: Success.
  • < 0: Failure.

◆ publishVideo()

native int io.agora.rtc.AgoraLocalUser.publishVideo ( AgoraLocalVideoTrack  agora_local_video_track)

Publishes a local video track to the channel.

Parameters
agora_local_video_trackThe local video track to be published.
Returns
  • 0: Success.
  • < 0: Failure.

◆ registerAudioFrameObserver()

native int io.agora.rtc.AgoraLocalUser.registerAudioFrameObserver ( IAudioFrameObserver  observer)

Registers an audio frame observer.

You need to implement the IAudioFrameObserver class in this method, and register the following callbacks according to your scenario:

Parameters
observerThe audio frame observer: IAudioFrameObserver.
Returns
  • 0: Success.
  • < 0: Failure.

◆ registerObserver()

native int io.agora.rtc.AgoraLocalUser.registerObserver ( ILocalUserObserver  observer)

Registers a local user observer object.

You need to implement the ILocalUserObserver class in this method. Once registered, the ILocalUserObserver receives events of the AgoraLocalUser object.

Parameters
observerThe ILocalUserObserver object.
Returns
  • 0: Success.
  • < 0: Failure.

◆ sendIntraRequest()

native int io.agora.rtc.AgoraLocalUser.sendIntraRequest ( String  uid)

Sends intra-frame request to the broadcaster with a specified uid.

The local user receives the onIntraRequestReceived callback when the broadcaster receives the request.

Parameters
uidThe user ID of the target broadcaster .
Returns
  • 0: Success.
  • < 0: Failure.

◆ setAudioEncoderConfig()

native int io.agora.rtc.AgoraLocalUser.setAudioEncoderConfig ( AudioEncoderConfig  config)

Configures the audio encoder.

The SDK applies the configurations to all the sending audio tracks.

Parameters
configThe reference to the audio encoder configurations.
Returns
  • 0: Success.
  • < 0: Failure.

◆ setAudioVolumeIndicationParameters()

native int io.agora.rtc.AgoraLocalUser.setAudioVolumeIndicationParameters ( int  interval_in_ms,
int  smooth,
boolean  report_vad 
)

◆ setMixedAudioFrameParameters()

native int io.agora.rtc.AgoraLocalUser.setMixedAudioFrameParameters ( int  channels,
int  sample_rate_hz,
int  mode,
int  samples_per_call 
)

Sets the audio frame parameters for the onMixedAudioFrame callback.

Parameters
channelsThe number of channels of the audio frame in the onMixedAudioFrame callback.
  • 1: Mono.
  • 2: Stereo.
sample_rate_hzThe sample rate (Hz) of the audio frame in the onMixedAudioFrame callback. You can set it as 8000, 16000, 32000, 44100, or 48000.
modeThe use mode of the onMixedAudioFrame callback:
  • 0: Read-only mode: Users only read the AudioFrame data without modifying anything. For example, when users acquire the data with the Agora SDK then push the RTMP or RTMPS streams.
  • 1: Write-only mode: Users replace the AudioFrame data with their own data. For example, users can use this mode when they acquire data by themselves.
  • 2: Read and write mode: Users read the data from AudioFrame, modify it, and then play it. For example, users can use this mode when they have their own sound-effect processing module, and want to do some voice post-processing, such as a voice change.
samples_per_callThe number of samples the onMixedAudioFrame callback returns. In RTMP or RTMPS streaming scenarios, set it as 1024.
Returns
  • 0: Success.
  • < 0: Failure.

◆ setPlaybackAudioFrameBeforeMixingParameters()

native int io.agora.rtc.AgoraLocalUser.setPlaybackAudioFrameBeforeMixingParameters ( int  channels,
int  sample_rate_hz,
int  mode,
int  samples_per_call 
)

Sets the audio frame parameters for the onPlaybackAudioFrameBeforeMixing callback.

Parameters
channelsThe number of channels of the audio frame in the onPlaybackAudioFrameBeforeMixing callback.
  • 1: Mono.
  • 2: Stereo.
sample_rate_hzThe sample rate (Hz) of the audio frame in the onPlaybackAudioFrameBeforeMixing callback. You can set it as 8000, 16000, 32000, 44100, or 48000.
modeThe use mode of the onPlaybackAudioFrameBeforeMixing callback:
  • 0: Read-only mode: Users only read the AudioFrame data without modifying anything. For example, when users acquire the data with the Agora SDK then push the RTMP or RTMPS streams.
  • 1: Write-only mode: Users replace the AudioFrame data with their own data. For example, users can use this mode when they acquire data by themselves.
  • 2: Read and write mode: Users read the data from AudioFrame, modify it, and then play it. For example, users can use this mode when they have their own sound-effect processing module, and want to do some voice post-processing, such as a voice change.
samples_per_callThe number of samples the onPlaybackAudioFrameBeforeMixing callback returns. In RTMP or RTMPS streaming scenarios, set it as 1024.
Returns
  • 0: Success.
  • < 0: Failure.

◆ setPlaybackAudioFrameParameters()

native int io.agora.rtc.AgoraLocalUser.setPlaybackAudioFrameParameters ( int  channels,
int  sample_rate_hz,
int  mode,
int  samples_per_call 
)

Sets the audio frame parameters for the onPlaybackAudioFrame callback.

Parameters
channelsThe number of audio channels of the audio frame in the onPlaybackAudioFrame callback.
  • 1: Mono.
  • 2: Stereo.
sample_rate_hzThe sample rate (Hz) of the audio frame in the onPlaybackAudioFrame callback. You can set it as 8000, 16000, 32000, 44100, or 48000.
modeThe use mode of the onPlaybackAudioFrame callback:
  • 0: Read-only mode: Users only read the AudioFrame data without modifying anything. For example, when users acquire the data with the Agora SDK then push the RTMP or RTMPS streams.
  • 1: Write-only mode: Users replace the AudioFrame data with their own data. For example, users can use this mode when they acquire data by themselves.
  • 2: Read and write mode: Users read the data from AudioFrame, modify it, and then play it. For example, users can use this mode when they have their own sound-effect processing module, and want to do some voice post-processing, such as a voice change.
samples_per_callThe number of samples the onPlaybackAudioFrame callback returns. In RTMP or RTMPS streaming scenarios, set it as 1024.
Returns
  • 0: Success.
  • < 0: Failure.

◆ setRecordingAudioFrameParameters()

native int io.agora.rtc.AgoraLocalUser.setRecordingAudioFrameParameters ( int  channels,
int  sample_rate_hz,
int  mode,
int  samples_per_call 
)

Sets the audio frame parameters for the onRecordAudioFrame callback.

Parameters
channelsThe number of channels of the audio frame in the onRecordAudioFrame callback.
  • 1: Mono.
  • 2: Stereo.
sample_rate_hzThe sample rate (Hz) of the audio frame in the onRecordAudioFrame callback. You can set it as 8000, 16000, 32000, 44100, or 48000.
modeThe use mode of the onRecordAudioFrame callback:
  • 0: Read-only mode: Users only read the AudioFrame data without modifying anything. For example, when users acquire the data with the Agora SDK then push the RTMP or RTMPS streams.
  • 1: Write-only mode: Users replace the AudioFrame data with their own data. For example, users can use this mode when they acquire data by themselves.
  • 2: Read and write mode: Users read the data from AudioFrame, modify it, and then play it. For example, users can use this mode when they have their own sound-effect processing module, and want to do some voice post-processing, such as a voice change.
samples_per_callThe number of samples the onRecordFrame callback returns. In RTMP or RTMPS streaming scenarios, set it as 1024.
Returns
  • 0: Success.
  • < 0: Failure.

◆ setUserRole()

native void io.agora.rtc.AgoraLocalUser.setUserRole ( int  role)

Sets the role of the user.

You can call this method either before or after connecting to an Agora channel:

  • Before connecting: This method sets the user role as publisher or subscriber (default).
  • After connecting: This method allows you to switch the user role between publisher and subscriber. The onChangeRoleSuccess and onChangeRoleFailure callbacks indicate the result of this method call.
Note
If the token in the connect method does not have the same role as role, the connection fails with the onConnectionFailure callback.
Parameters
roleThe role of the user.

◆ subscribeAllAudio()

native int io.agora.rtc.AgoraLocalUser.subscribeAllAudio ( )

Subscribes to the audio of all remote users in the channel.

This method also automatically subscribes to the audio of any subsequent user.

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

◆ subscribeAllVideo()

native int io.agora.rtc.AgoraLocalUser.subscribeAllVideo ( VideoSubscriptionOptions  options)

Subscribes to the video of all remote users in the channel.

This method also automatically subscribes to the video of any subsequent remote user.

Parameters
optionsThe reference to the video subscription options: VideoSubscriptionOptions.
Returns
  • 0: Success.
  • < 0: Failure.

◆ subscribeAudio()

native int io.agora.rtc.AgoraLocalUser.subscribeAudio ( String  user_id)

Subscribes to the audio of a specified remote user in channel.

Parameters
user_idThe ID of the remote user whose audio you want to subscribe to.
Returns
  • 0: Success.
  • < 0: Failure.

◆ subscribeVideo()

native int io.agora.rtc.AgoraLocalUser.subscribeVideo ( String  user_id,
VideoSubscriptionOptions  options 
)

Subscribes to the video of a specified remote user in the channel.

Parameters
user_idThe ID of the user whose video you want to subscribe to.
optionsThe reference to the video subscription options. For example, subscribing to encoded video data only or subscribing to low-stream video.
Returns
  • 0: Success.
  • < 0: Failure.

◆ unpublishAudio()

native int io.agora.rtc.AgoraLocalUser.unpublishAudio ( AgoraLocalAudioTrack  agora_local_audio_track)

Stops publishing the local audio track to the channel.

Parameters
agora_local_audio_trackThe local audio track that you want to stop publishing.
Returns
  • 0: Success.
  • < 0: Failure.

◆ unpublishVideo()

native int io.agora.rtc.AgoraLocalUser.unpublishVideo ( AgoraLocalVideoTrack  agora_local_video_track)

Stops publishing the local video track to the channel.

Parameters
agora_local_video_trackThe local video track that you want to stop publishing.
Returns
  • 0: Success.
  • < 0: Failure.

◆ unregisterAudioFrameObserver()

native int io.agora.rtc.AgoraLocalUser.unregisterAudioFrameObserver ( )

Releases the audio frame observer.

Parameters
observerThe audio frame observer: IAudioFrameObserver.
Returns
  • 0: Success.
  • < 0: Failure.

◆ unregisterObserver()

native int io.agora.rtc.AgoraLocalUser.unregisterObserver ( )

Releases the ILocalUserObserver object.

Parameters
observerThe pointer to the ILocalUserObserver object that you want to release.
Returns
  • 0: Success.
  • < 0: Failure.

◆ unsubscribeAllAudio()

native int io.agora.rtc.AgoraLocalUser.unsubscribeAllAudio ( )

Stops subscribing to the audio of all remote users in the channel.

This method automatically stops subscribing to the audio of any subsequent user, unless you explicitly call subscribeAudio or subscribeAllAudio.

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

◆ unsubscribeAllVideo()

native int io.agora.rtc.AgoraLocalUser.unsubscribeAllVideo ( )

Stops subscribing to the video of all remote users in the channel.

This method automatically stops subscribing to the video of any subsequent user, unless you explicitly call subscribeVideo or subscribeAllVideo.

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

◆ unsubscribeAudio()

native int io.agora.rtc.AgoraLocalUser.unsubscribeAudio ( String  user_id)

Stops subscribing to the audio of a specified remote user in the channel.

Parameters
user_idThe ID of the user whose audio you want to stop subscribing to.
Returns
  • 0: Success.
  • < 0: Failure.

◆ unsubscribeVideo()

native int io.agora.rtc.AgoraLocalUser.unsubscribeVideo ( String  user_id)

Stops subscribing to the video of a specified remote user in the channel.

Parameters
user_idThe ID of the user whose video you want to stop subscribing to.
Returns
  • 0: Success.
  • < 0: Failure.

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