◆ AgoraLocalAudioTrack()
io.agora.rtc.AgoraLocalAudioTrack.AgoraLocalAudioTrack |
( |
long |
cptr | ) |
|
◆ adjustPublishVolume()
native int io.agora.rtc.AgoraLocalAudioTrack.adjustPublishVolume |
( |
int |
volume | ) |
|
Adjusts the audio volume for publishing.
- Parameters
-
volume | The volume for publishing. The value ranges between 0 and 100 (default). |
- Returns
- 0: Success.
- < 0: Failure.
◆ clearSenderBuffer()
native int io.agora.rtc.AgoraLocalAudioTrack.clearSenderBuffer |
( |
| ) |
|
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.
◆ destroy()
void io.agora.rtc.AgoraLocalAudioTrack.destroy |
( |
| ) |
|
◆ destroyStats()
◆ getPublishVolume()
native int io.agora.rtc.AgoraLocalAudioTrack.getPublishVolume |
( |
Out |
volume | ) |
|
Gets the current volume for publishing.
- Parameters
-
volume | The publishing volume. |
- Returns
- 0: Success.
- < 0: Failure.
◆ getState()
native int io.agora.rtc.AgoraLocalAudioTrack.getState |
( |
| ) |
|
Gets the state of the local audio.
- Returns
- The state of the local audio.
◆ getStats()
Gets the statistics of the local audio track.
- Returns
- The statistics of the local audio.
◆ isEnabled()
native int io.agora.rtc.AgoraLocalAudioTrack.isEnabled |
( |
| ) |
|
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.
◆ setEnabled()
native void io.agora.rtc.AgoraLocalAudioTrack.setEnabled |
( |
int |
enable | ) |
|
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.
|
◆ setMaxBufferedAudioFrameNumber()
native void io.agora.rtc.AgoraLocalAudioTrack.setMaxBufferedAudioFrameNumber |
( |
int |
number | ) |
|
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 setSendDelayMs 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. |
◆ setSendDelayMs()
native void io.agora.rtc.AgoraLocalAudioTrack.setSendDelayMs |
( |
int |
delayMs | ) |
|
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. |
The documentation for this class was generated from the following file: