Agora Server Gateway SDK C++ API Reference
Public Member Functions | List of all members
agora::rtc::ILocalUser Class Referenceabstract

#include <NGIAgoraLocalUser.h>

Public Member Functions

virtual ~ILocalUser ()
 
virtual void setUserRole (rtc::CLIENT_ROLE_TYPE role)=0
 
virtual CLIENT_ROLE_TYPE getUserRole ()=0
 
virtual int setAudioEncoderConfiguration (const rtc::AudioEncoderConfiguration &config)=0
 
virtual int publishAudio (agora_refptr< ILocalAudioTrack > audioTrack)=0
 
virtual int unpublishAudio (agora_refptr< ILocalAudioTrack > audioTrack)=0
 
virtual int publishVideo (agora_refptr< ILocalVideoTrack > videoTrack)=0
 
virtual int unpublishVideo (agora_refptr< ILocalVideoTrack > videoTrack)=0
 
virtual int subscribeAudio (user_id_t userId)=0
 
virtual int subscribeAllAudio ()=0
 
virtual int unsubscribeAudio (user_id_t userId)=0
 
virtual int unsubscribeAllAudio ()=0
 
virtual int setPlaybackAudioFrameParameters (size_t numberOfChannels, uint32_t sampleRateHz, RAW_AUDIO_FRAME_OP_MODE_TYPE mode=RAW_AUDIO_FRAME_OP_MODE_READ_ONLY, int samplesPerCall=0)=0
 
virtual int setRecordingAudioFrameParameters (size_t numberOfChannels, uint32_t sampleRateHz, RAW_AUDIO_FRAME_OP_MODE_TYPE mode=RAW_AUDIO_FRAME_OP_MODE_READ_ONLY, int samplesPerCall=0)=0
 
virtual int setMixedAudioFrameParameters (size_t numberOfChannels, uint32_t sampleRateHz, int samplesPerCall=0)=0
 
virtual int setPlaybackAudioFrameBeforeMixingParameters (size_t numberOfChannels, uint32_t sampleRateHz)=0
 
virtual int registerAudioFrameObserver (agora::media::IAudioFrameObserverBase *observer)=0
 
virtual int unregisterAudioFrameObserver (agora::media::IAudioFrameObserverBase *observer)=0
 
virtual int registerVideoEncodedFrameObserver (agora::media::IVideoEncodedFrameObserver *observer)=0
 
virtual int unregisterVideoEncodedFrameObserver (agora::media::IVideoEncodedFrameObserver *observer)=0
 
virtual int registerVideoFrameObserver (IVideoFrameObserver2 *observer)=0
 
virtual int unregisterVideoFrameObserver (IVideoFrameObserver2 *observer)=0
 
virtual int subscribeVideo (user_id_t userId, const rtc::VideoSubscriptionOptions &subscriptionOptions)=0
 
virtual int subscribeAllVideo (const rtc::VideoSubscriptionOptions &subscriptionOptions)=0
 
virtual int unsubscribeVideo (user_id_t userId)=0
 
virtual int unsubscribeAllVideo ()=0
 
virtual int registerLocalUserObserver (ILocalUserObserver *observer, void(*safeDeleter)(ILocalUserObserver *)=NULL)=0
 
virtual int unregisterLocalUserObserver (ILocalUserObserver *observer)=0
 
virtual int sendIntraRequest (user_id_t userId)=0
 

Detailed Description

The ILocalUser class defines the behavior and state of a local user.

Each RTC connection has its own local user. Apps can get the local user object by calling IRtcConnection::getLocalUser.

Each local user has two user roles: broadcaster (publisher and subscriber) and audience (subscriber only). A publisher publishes audio and video tracks, while audience receive them.

Constructor & Destructor Documentation

◆ ~ILocalUser()

virtual agora::rtc::ILocalUser::~ILocalUser ( )
inlinevirtual

Member Function Documentation

◆ getUserRole()

virtual CLIENT_ROLE_TYPE agora::rtc::ILocalUser::getUserRole ( )
pure virtual

Gets the role of the user.

Returns
The role of the user: Success.

◆ publishAudio()

virtual int agora::rtc::ILocalUser::publishAudio ( agora_refptr< ILocalAudioTrack audioTrack)
pure virtual

Publishes a local audio track to the channel.

By default, all published audio tracks are mixed.

Parameters
audioTrackThe local audio track to be published.
Returns
  • 0: Success.
  • < 0: Failure.
    • -5(ERR_REFUSED), if the role of the local user is not broadcaster.

◆ publishVideo()

virtual int agora::rtc::ILocalUser::publishVideo ( agora_refptr< ILocalVideoTrack videoTrack)
pure virtual

Publishes a local video track to the channel.

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

◆ registerAudioFrameObserver()

virtual int agora::rtc::ILocalUser::registerAudioFrameObserver ( agora::media::IAudioFrameObserverBase *  observer)
pure virtual

Registers an audio frame observer.

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

  • onRecordAudioFrame: Occurs when the SDK receives the audio data captured by the local recording device.
  • onPlaybackAudioFrame: Occurs when the SDK receives the remote audio data for playback.
  • onPlaybackAudioFrameBeforeMixing: Occurs when the SDK receives the remote audio data of a specified remote user before mixing.
  • onMixedAudioFrame: Occurs when the SDK receives the mixed data of recorded and playback audio.
Parameters
observerA pointer to the audio frame observer: IAudioFrameObserverBase.
Returns
  • 0: Success.
  • < 0: Failure.

◆ registerLocalUserObserver()

virtual int agora::rtc::ILocalUser::registerLocalUserObserver ( ILocalUserObserver observer,
void(*)(ILocalUserObserver *)  safeDeleter = NULL 
)
pure virtual

Registers a local user observer object.

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

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

◆ registerVideoEncodedFrameObserver()

virtual int agora::rtc::ILocalUser::registerVideoEncodedFrameObserver ( agora::media::IVideoEncodedFrameObserver *  observer)
pure virtual

Registers an IVideoEncodedFrameObserver object.

You need to implement the IVideoEncodedFrameObserver class in this method. Once you successfully register the encoded frame observer, the SDK triggers the OnEncodedVideoFrame callback when it receives the encoded video image.

Parameters
observerThe pointer to the IVideoEncodedFrameObserver object.
Returns
  • 0: Success.
  • < 0: Failure.

◆ registerVideoFrameObserver()

virtual int agora::rtc::ILocalUser::registerVideoFrameObserver ( IVideoFrameObserver2 observer)
pure virtual

Registers an IVideoFrameObserver2 object.

You need to implement the IVideoFrameObserver2 class in this method. Once you successfully register the video frame observer, the SDK triggers the onFrame callback when it receives the video image.

Parameters
observerThe pointer to the IVideoFrameObserver2 object.
Returns
  • 0: Success.
  • < 0: Failure.

◆ sendIntraRequest()

virtual int agora::rtc::ILocalUser::sendIntraRequest ( user_id_t  userId)
pure virtual

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

After you successfully send the request, the host receives the onIntraRequestReceived callback.

Parameters
userIdThe user ID of the host.
Returns
  • 0: Success.
  • < 0: Failure.

◆ setAudioEncoderConfiguration()

virtual int agora::rtc::ILocalUser::setAudioEncoderConfiguration ( const rtc::AudioEncoderConfiguration config)
pure virtual

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.

◆ setMixedAudioFrameParameters()

virtual int agora::rtc::ILocalUser::setMixedAudioFrameParameters ( size_t  numberOfChannels,
uint32_t  sampleRateHz,
int  samplesPerCall = 0 
)
pure virtual

Sets the audio frame parameters for the onMixedAudioFrame callback.

Parameters
numberOfChannelsThe number of channels of the audio frame in the onMixedAudioFrame callback.
  • 1: Mono.
  • 2: Stereo.
sampleRateHzThe sample rate (Hz) of the audio frame in the onMixedAudioFrame callback. You can set it as 8000, 16000, 32000, 44100, or 48000.
samplesPerCallSets the number of samples returned in the onMixedAudioFrame callback. samplesPerCall is usually set as 1024 for CDN streaming.
Returns
  • 0: Success.
  • < 0: Failure.

◆ setPlaybackAudioFrameBeforeMixingParameters()

virtual int agora::rtc::ILocalUser::setPlaybackAudioFrameBeforeMixingParameters ( size_t  numberOfChannels,
uint32_t  sampleRateHz 
)
pure virtual

Sets the audio frame parameters for the onPlaybackAudioFrameBeforeMixing callback.

Parameters
numberOfChannelsThe number of channels of the audio frame in the onPlaybackAudioFrameBeforeMixing callback.
  • 1: Mono.
  • 2: Stereo.
sampleRateHzThe sample rate (Hz) of the audio frame in the onPlaybackAudioFrameBeforeMixing callback. You can set it as 8000, 16000, 32000, 44100, or 48000.
Returns
  • 0: Success.
  • < 0: Failure.

◆ setPlaybackAudioFrameParameters()

virtual int agora::rtc::ILocalUser::setPlaybackAudioFrameParameters ( size_t  numberOfChannels,
uint32_t  sampleRateHz,
RAW_AUDIO_FRAME_OP_MODE_TYPE  mode = RAW_AUDIO_FRAME_OP_MODE_READ_ONLY,
int  samplesPerCall = 0 
)
pure virtual

Sets the audio frame parameters for the onPlaybackAudioFrame callback.

Parameters
numberOfChannelsThe number of audio channels of the audio frame in the onPlaybackAudioFrame callback.
  • 1: Mono.
  • 2: Stereo.
sampleRateHzThe sample rate (Hz) of the audio frame in the onPlaybackAudioFrame callback. You can set it as 8000, 16000, 32000, 44100, or 48000.
modeUse mode of the audio frame. See RAW_AUDIO_FRAME_OP_MODE_TYPE.
samplesPerCallThe number of samples of the audio frame.
Returns
  • 0: Success.
  • < 0: Failure.

◆ setRecordingAudioFrameParameters()

virtual int agora::rtc::ILocalUser::setRecordingAudioFrameParameters ( size_t  numberOfChannels,
uint32_t  sampleRateHz,
RAW_AUDIO_FRAME_OP_MODE_TYPE  mode = RAW_AUDIO_FRAME_OP_MODE_READ_ONLY,
int  samplesPerCall = 0 
)
pure virtual

Sets the audio frame parameters for the onRecordAudioFrame callback.

Parameters
numberOfChannelsThe number of channels of the audio frame in the onRecordAudioFrame callback.
  • 1: Mono.
  • 2: Stereo.
sampleRateHzThe sample rate (Hz) of the audio frame in the onRecordAudioFrame callback. You can set it as 8000, 16000, 32000, 44100, or 48000.
modeUse mode of the audio frame. See RAW_AUDIO_FRAME_OP_MODE_TYPE.
samplesPerCallThe number of samples of the audio frame.
Returns
  • 0: Success.
  • < 0: Failure.

◆ setUserRole()

virtual void agora::rtc::ILocalUser::setUserRole ( rtc::CLIENT_ROLE_TYPE  role)
pure virtual

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. See CLIENT_ROLE_TYPE.

◆ subscribeAllAudio()

virtual int agora::rtc::ILocalUser::subscribeAllAudio ( )
pure virtual

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()

virtual int agora::rtc::ILocalUser::subscribeAllVideo ( const rtc::VideoSubscriptionOptions subscriptionOptions)
pure virtual

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
subscriptionOptionsThe reference to the video subscription options: VideoSubscriptionOptions.
Returns
  • 0: Success.
  • < 0: Failure.

◆ subscribeAudio()

virtual int agora::rtc::ILocalUser::subscribeAudio ( user_id_t  userId)
pure virtual

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

Parameters
userIdThe ID of the remote user whose audio you want to subscribe to.
Returns
  • 0: Success.
  • < 0: Failure.
    • -2(ERR_INVALID_ARGUMENT), if no such user exists or userId is invalid.

◆ subscribeVideo()

virtual int agora::rtc::ILocalUser::subscribeVideo ( user_id_t  userId,
const rtc::VideoSubscriptionOptions subscriptionOptions 
)
pure virtual

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

Parameters
userIdThe ID of the user whose video you want to subscribe to.
subscriptionOptionsThe reference to the video subscription options: VideoSubscriptionOptions. For example, subscribing to encoded video data only or subscribing to low-stream video.
Returns
  • 0: Success.
  • < 0: Failure.
    • -2(ERR_INVALID_ARGUMENT), if userId is invalid.

◆ unpublishAudio()

virtual int agora::rtc::ILocalUser::unpublishAudio ( agora_refptr< ILocalAudioTrack audioTrack)
pure virtual

Stops publishing the local audio track to the channel.

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

◆ unpublishVideo()

virtual int agora::rtc::ILocalUser::unpublishVideo ( agora_refptr< ILocalVideoTrack videoTrack)
pure virtual

Stops publishing the local video track to the channel.

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

◆ unregisterAudioFrameObserver()

virtual int agora::rtc::ILocalUser::unregisterAudioFrameObserver ( agora::media::IAudioFrameObserverBase *  observer)
pure virtual

Releases the audio frame observer.

Parameters
observerThe pointer to the audio frame observer: IAudioFrameObserverBase.
Returns
  • 0: Success.
  • < 0: Failure.

◆ unregisterLocalUserObserver()

virtual int agora::rtc::ILocalUser::unregisterLocalUserObserver ( ILocalUserObserver observer)
pure virtual

Releases the ILocalUserObserver object.

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

◆ unregisterVideoEncodedFrameObserver()

virtual int agora::rtc::ILocalUser::unregisterVideoEncodedFrameObserver ( agora::media::IVideoEncodedFrameObserver *  observer)
pure virtual

Releases the IVideoEncodedFrameObserver object.

Parameters
observerThe pointer to the IVideoEncodedFrameObserver object.
Returns
  • 0: Success.
  • < 0: Failure.

◆ unregisterVideoFrameObserver()

virtual int agora::rtc::ILocalUser::unregisterVideoFrameObserver ( IVideoFrameObserver2 observer)
pure virtual

Releases the IVideoFrameObserver2 object.

Parameters
observerThe pointer to the IVideoFrameObserver2 object.
Returns
  • 0: Success.
  • < 0: Failure.

◆ unsubscribeAllAudio()

virtual int agora::rtc::ILocalUser::unsubscribeAllAudio ( )
pure virtual

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()

virtual int agora::rtc::ILocalUser::unsubscribeAllVideo ( )
pure virtual

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()

virtual int agora::rtc::ILocalUser::unsubscribeAudio ( user_id_t  userId)
pure virtual

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

Parameters
userIdThe ID of the user whose audio you want to stop subscribing to.
Returns
  • 0: Success.
  • < 0: Failure.
    • -2(ERR_INVALID_ARGUMENT), if no such user exists or userId is invalid.

◆ unsubscribeVideo()

virtual int agora::rtc::ILocalUser::unsubscribeVideo ( user_id_t  userId)
pure virtual

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

Parameters
userIdThe ID of the user whose video you want to stop subscribing to.
Returns
  • 0: Success.
  • < 0: Failure.
    • -2(ERR_INVALID_ARGUMENT), if userId is invalid.

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