#include <NGIAgoraAudioTrack.h>
ILocalAudioTrack
is the base class for local audio tracks, providing main methods of local audio tracks.
◆ ~ILocalAudioTrack()
agora::rtc::ILocalAudioTrack::~ILocalAudioTrack |
( |
| ) |
|
|
inlineprotected |
◆ 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
-
volume | The volume for publishing. The value ranges between 0 and 100 (default). |
ares | This 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
-
volume | A pointer to the publishing volume. |
- Returns
- 0: Success.
- < 0: Failure.
◆ getState()
◆ GetStats()
◆ 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
-
delayMs | The 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
-
enable | Whether to enable the audio track:
true : Enable the local audio track.
false : Disable the local audio track.
|
ares | This 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
-
number | The maximum number of audio frames that the buffer can store. For example, setting 6000 means 6000 audio frames. |
ares | This parameter is used for the SDK lifecycle protection. Fill in the default value. |
The documentation for this class was generated from the following file: