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

#include <NGIAgoraAudioTrack.h>

Classes

struct  LocalAudioTrackStats
 

Public Member Functions

virtual void setEnabled (bool enable, aosl_ref_t ares=AOSL_REF_INVALID)=0
 
virtual bool isEnabled () const =0
 
virtual LOCAL_AUDIO_STREAM_STATE getState ()=0
 
virtual LocalAudioTrackStats GetStats ()=0
 
virtual int adjustPublishVolume (int volume, aosl_ref_t ares=AOSL_REF_INVALID)=0
 
virtual int getPublishVolume (int *volume)=0
 
virtual void setMaxBufferedAudioFrameNumber (int number, aosl_ref_t ares=AOSL_REF_INVALID)=0
 
virtual int ClearSenderBuffer ()=0
 
virtual void setAudioFrameSendDelayMs (int32_t delay_ms)=0
 
- Public Member Functions inherited from agora::rtc::IAudioTrack
virtual bool addAudioSink (agora_refptr< IAudioSinkBase > sink, const AudioSinkWants &wants, aosl_ref_t ares=AOSL_REF_INVALID)=0
 
virtual bool removeAudioSink (agora_refptr< IAudioSinkBase > sink, aosl_ref_t ares=AOSL_REF_INVALID)=0
 

Protected Member Functions

 ~ILocalAudioTrack ()
 

Additional Inherited Members

- Public Types inherited from agora::rtc::IAudioTrack
enum  AudioFilterPosition {
  RecordingLocalPlayback , PostAudioProcessing , RemoteUserPlayback , PcmSource ,
  PcmSourceSending , PcmSourceLocalPlayback , RemoteMixedPlayback
}
 

Detailed Description

ILocalAudioTrack is the base class for local audio tracks, providing main methods of local audio tracks.

Constructor & Destructor Documentation

◆ ~ILocalAudioTrack()

agora::rtc::ILocalAudioTrack::~ILocalAudioTrack ( )
inlineprotected

Member Function Documentation

◆ adjustPublishVolume()

virtual int agora::rtc::ILocalAudioTrack::adjustPublishVolume ( int  volume,
aosl_ref_t  ares = AOSL_REF_INVALID 
)
pure virtual

Adjusts the audio volume for publishing.

Parameters
volumeThe volume for publishing. The value ranges between 0 and 100 (default).
aresThis parameter is used for the SDK lifecycle protection. Fill in the default value.
Returns
  • 0: Success.
  • < 0: Failure.

◆ ClearSenderBuffer()

virtual int agora::rtc::ILocalAudioTrack::ClearSenderBuffer ( )
pure virtual

Clears the current audio send buffer.

Since
4.4.30

If you no longer need the data in the current audio send buffer, you can call this method to clear the buffer. For example, if a user asks an AI bot a question and the AI bot is transmitting audio to the user through the SDK, the audio send buffer of the SDK continuously receives and sends data. When the user interrupts the AI bot's response and asks another question, you can call this method to clear the unsent buffered data, allowing the AI to quickly buffer the response to the new topic.

Returns
  • ≥ 0: Success, returning the number of cleared audio frames.
  • < 0: Failure.

◆ getPublishVolume()

virtual int agora::rtc::ILocalAudioTrack::getPublishVolume ( int *  volume)
pure virtual

Gets the current volume for publishing.

Parameters
volumeA pointer to the publishing volume.
Returns
  • 0: Success.
  • < 0: Failure.

◆ getState()

virtual LOCAL_AUDIO_STREAM_STATE agora::rtc::ILocalAudioTrack::getState ( )
pure virtual

Gets the state of the local audio.

Returns
The state of the local audio: LOCAL_AUDIO_STREAM_STATE: Success.

◆ GetStats()

virtual LocalAudioTrackStats agora::rtc::ILocalAudioTrack::GetStats ( )
pure virtual

Gets the statistics of the local audio track: LocalAudioTrackStats.

Returns
The statistics of the local audio: LocalAudioTrackStats: Success.

◆ isEnabled()

virtual bool agora::rtc::ILocalAudioTrack::isEnabled ( ) const
pure virtual

Gets whether the local audio track is enabled.

Returns
Whether the local audio track is enabled:
  • true: The local track is enabled.
  • false: The local track is disabled.

◆ setAudioFrameSendDelayMs()

virtual void agora::rtc::ILocalAudioTrack::setAudioFrameSendDelayMs ( int32_t  delay_ms)
pure virtual

Sets the minimum data duration allowed for sending in the audio send buffer.

Since
4.4.30

The SDK's default minimum data duration allowed for sending is 160 ms, meaning the SDK will wait and send the data to the receiver once the audio send buffer is filled with 160 ms of audio data. This has the following effects:

  • If the sender sends data greater than or equal to 160 ms at a time, such as 800 ms, the SDK will immediately send data to the receiver at a frequency of 10 ms per frame.
  • If the sender sends data less than 160 ms at a time, such as 100 ms, the SDK will wait and send the data to the receiver once the audio send buffer is filled with 160 ms. This causes a delay of up to 60 ms.

You can adjust the minimum data duration allowed for sending in the buffer according to actual business needs by calling this method.

Parameters
delayMsThe minimum data duration allowed for sending in the buffer (ms). Set this parameter as a multiple of 10, with a value greater than 0 and less than 10 times the number parameter in the setMaxBufferedAudioFrameNumber method.

◆ setEnabled()

virtual void agora::rtc::ILocalAudioTrack::setEnabled ( bool  enable,
aosl_ref_t  ares = AOSL_REF_INVALID 
)
pure virtual

Enables or disables the local audio track.

Once the local audio is enabled, the SDK allows for local audio capturing, processing, and encoding.

Parameters
enableWhether to enable the audio track:
  • true: Enable the local audio track.
  • false: Disable the local audio track.
aresThis parameter is used for the SDK lifecycle protection. Fill in the default value.

◆ setMaxBufferedAudioFrameNumber()

virtual void agora::rtc::ILocalAudioTrack::setMaxBufferedAudioFrameNumber ( int  number,
aosl_ref_t  ares = AOSL_REF_INVALID 
)
pure virtual

Sets the maximum capacity of the audio send buffer.

Since
4.4.30

In application scenarios such as AI interaction, the frequency of sending audio frames may be uneven. For example, sometimes the sender sends 1 audio frame in 20 ms, but sometimes 3 audio frame in 20 ms. If the SDK sends data to the Agora server according to the actual sending frequency, the receiver may experience issues such as stuttering or frame loss. To optimize audio transmission performance, the SDK sets an audio send buffer. Regardless of the actual frequency of sending audio frames from the sender, the SDK stores the data in the audio send buffer. Once the data in the audio send buffer reaches the minimum duration allowed for sending, the SDK starts sending data to the receiver at a frequency of 10 ms per frame.

The default maximum capacity of the SDK's audio send buffer is 6000, which means it can store up to 6000 audio frames, equivalent to 60 seconds of data. If you need a larger buffer capacity, you can call this method to adjust it. If you also need to set the minimum data duration allowed for sending in the audio send buffer, call the setAudioFrameSendDelayMs method.

Note
This method needs to be called before the publishAudio method.
Parameters
numberThe maximum number of audio frames that the buffer can store. For example, setting 6000 means 6000 audio frames.
aresThis parameter is used for the SDK lifecycle protection. Fill in the default value.

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