io.agora.rtc

## Class AgoraLocalAudioTrack

- java.lang.Object
- - io.agora.rtc.AgoraLocalAudioTrack

-     public class AgoraLocalAudioTrack
      extends java.lang.Object

  Represents a local audio track for publishing audio to a channel.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `private long` | `cptr` Native pointer to the local audio track resource.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AgoraLocalAudioTrack(long cptr)` Constructor for AgoraLocalAudioTrack.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `(package private) int` | `adjustPublishVolume(int volume)` Adjusts the publish volume of the local audio track.
    `(package private) int` | `clearSenderBuffer()` Clears the sender buffer.
    `(package private) void` | `destroy()` Destroys the local audio track.
    `(package private) void` | `destroyStats(LocalAudioTrackStats stats)` Destroys the provided LocalAudioTrackStats object.
    `(package private) int` | `enableEarMonitor(int enable, int includeAudiFilter)` Enables or disables ear monitoring.
    `(package private) int` | `enableLocalPlayback(int enable)` Enables or disables local playback of the audio track.
    `(package private) long` | `getNativeHandle()` Gets the native handle of the local audio track.
    `(package private) int` | `getPublishVolume(Out<java.lang.Integer> volume)` Gets the current publish volume of the local audio track.
    `(package private) int` | `getState()` Gets the current state of the local audio track.
    `(package private) LocalAudioTrackStats` | `getStats()` Retrieves the statistics of the local audio track.
    `(package private) int` | `isEnabled()` Checks if the local audio track is enabled.
    `private int` | `nativeAdjustPublishVolume(long cptr, int volume)` Adjusts publish volume in the native layer.
    `private int` | `nativeClearSenderBuffer(long cptr)` Clears buffered audio frames in the native sender.
    `private void` | `nativeDestroy(long cptr)` Releases the native audio track handle.
    `private void` | `nativeDestroyStats(long cptr, LocalAudioTrackStats stats)` Releases a statistics object that was created natively.
    `private int` | `nativeEnableEarMonitor(long cptr, int enable, int includeAudiFilter)` Enables or disables ear monitoring through the native API.
    `private int` | `nativeEnableLocalPlayback(long cptr, int enable)` Enables or disables local playback of the audio track natively.
    `private int` | `nativeGetPublishVolume(long cptr, Out<java.lang.Integer> volume)` Retrieves the publish volume from the native layer.
    `private int` | `nativeGetState(long cptr)` Retrieves the native state value of the audio track.
    `private LocalAudioTrackStats` | `nativeGetStats(long cptr)` Obtains statistics for the audio track from the native layer.
    `private int` | `nativeIsEnabled(long cptr)` Queries whether the audio track is enabled in the native layer.
    `private void` | `nativeSetEnabled(long cptr, int enable)` Enables or disables the audio track at the native layer.
    `private void` | `nativeSetMaxBufferedAudioFrameNumber(long cptr, int number)` Sets the maximum buffered frame count for the native audio sender.
    `private void` | `nativeSetSendDelayMs(long cptr, int delayMs)` Adjusts the native send delay in milliseconds.
    `private int` | `nativeSetTotalExtraSendMs(long cptr, long totalExtraSendMs)` Sets the total extra send time in milliseconds at the native layer.
    `(package private) void` | `setEnabled(int enable)` Enables or disables the local audio track.
    `(package private) void` | `setMaxBufferedAudioFrameNumber(int number)` Sets the maximum number of buffered audio frames.
    `(package private) void` | `setSendDelayMs(int delayMs)` Sets the send delay in milliseconds.
    `(package private) int` | `setTotalExtraSendMs(long totalExtraSendMs)` Sets the total extra send time in milliseconds.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### cptr

          private long cptr

      Native pointer to the local audio track resource.

  - ### Constructor Detail

    - #### AgoraLocalAudioTrack

          AgoraLocalAudioTrack(long cptr)

      Constructor for AgoraLocalAudioTrack.
      Parameters:
        `cptr` - Pointer to the native audio track object.

  - ### Method Detail

    - #### getNativeHandle

          long getNativeHandle()

      Gets the native handle of the local audio track.
      Returns:
        The native handle of the local audio track.

    - #### destroy

          void destroy()

      Destroys the local audio track. Ensures that the native resources are released.

    - #### setEnabled

          void setEnabled(int enable)

      Enables or disables the local audio track.
      Parameters:
        `enable` - 1 to enable, 0 to disable.

    - #### isEnabled

          int isEnabled()

      Checks if the local audio track is enabled.
      Returns:
        1 if enabled, 0 if disabled.

    - #### getState

          int getState()

      Gets the current state of the local audio track.
      Returns:
        The state of the audio track.

    - #### getStats

          LocalAudioTrackStats getStats()

      Retrieves the statistics of the local audio track.
      Returns:
        An instance of LocalAudioTrackStats containing the statistics.

    - #### destroyStats

          void destroyStats(LocalAudioTrackStats stats)

      Destroys the provided LocalAudioTrackStats object.
      Parameters:
        `stats` - The LocalAudioTrackStats object to be destroyed.

    - #### adjustPublishVolume

          int adjustPublishVolume(int volume)

      Adjusts the publish volume of the local audio track.
      Parameters:
        `volume` - The volume level to set.
      Returns:
        0 on success, <0 on failure.

    - #### getPublishVolume

          int getPublishVolume(Out<java.lang.Integer> volume)

      Gets the current publish volume of the local audio track.
      Parameters:
        `volume` - An Out object to store the volume level.
      Returns:
        0 on success, <0 on failure.

    - #### enableLocalPlayback

          int enableLocalPlayback(int enable)

      Enables or disables local playback of the audio track.
      Parameters:
        `enable` - 1 to enable, 0 to disable.
      Returns:
        0 on success, <0 on failure.

    - #### enableEarMonitor

          int enableEarMonitor(int enable,
                               int includeAudiFilter)

      Enables or disables ear monitoring.
      Parameters:
        `enable` - 1 to enable, 0 to disable.
        `includeAudiFilter` - 1 to include audio filter, 0 to exclude.
      Returns:
        0 on success, <0 on failure.

    - #### setMaxBufferedAudioFrameNumber

          void setMaxBufferedAudioFrameNumber(int number)

      Sets the maximum number of buffered audio frames.
      Parameters:
        `number` - The maximum number of frames to buffer.

    - #### clearSenderBuffer

          int clearSenderBuffer()

      Clears the sender buffer.
      Returns:
        0 on success, <0 on failure.

    - #### setSendDelayMs

          void setSendDelayMs(int delayMs)

      Sets the send delay in milliseconds.
      Parameters:
        `delayMs` - The delay in milliseconds.

    - #### setTotalExtraSendMs

          int setTotalExtraSendMs(long totalExtraSendMs)

      Sets the total extra send time in milliseconds.

      This method is used for AI server limited mode to set the total duration for fast transmission of audio frames.

      Parameters:
        `totalExtraSendMs` - The total extra send time in milliseconds.
      Returns:
        0 on success, <0 on failure.

    - #### nativeDestroy

          private void nativeDestroy(long cptr)

      Releases the native audio track handle.
      Parameters:
        `cptr` - Native pointer to the audio track

    - #### nativeSetEnabled

          private void nativeSetEnabled(long cptr,
                                        int enable)

      Enables or disables the audio track at the native layer.
      Parameters:
        `cptr` - Native pointer to the audio track
        `enable` - 1 to enable, 0 to disable

    - #### nativeIsEnabled

          private int nativeIsEnabled(long cptr)

      Queries whether the audio track is enabled in the native layer.
      Parameters:
        `cptr` - Native pointer to the audio track
      Returns:
        1 if enabled, 0 if disabled

    - #### nativeGetState

          private int nativeGetState(long cptr)

      Retrieves the native state value of the audio track.
      Parameters:
        `cptr` - Native pointer to the audio track
      Returns:
        The state of the audio track

    - #### nativeGetStats

          private LocalAudioTrackStats nativeGetStats(long cptr)

      Obtains statistics for the audio track from the native layer.
      Parameters:
        `cptr` - Native pointer to the audio track
      Returns:
        Statistics object for the audio track

    - #### nativeDestroyStats

          private void nativeDestroyStats(long cptr,
                                          LocalAudioTrackStats stats)

      Releases a statistics object that was created natively.
      Parameters:
        `cptr` - Native pointer to the audio track
        `stats` - Statistics object to destroy

    - #### nativeAdjustPublishVolume

          private int nativeAdjustPublishVolume(long cptr,
                                                int volume)

      Adjusts publish volume in the native layer.
      Parameters:
        `cptr` - Native pointer to the audio track
        `volume` - Volume level to set
      Returns:
        0 on success, <0 on failure

    - #### nativeGetPublishVolume

          private int nativeGetPublishVolume(long cptr,
                                             Out<java.lang.Integer> volume)

      Retrieves the publish volume from the native layer.
      Parameters:
        `cptr` - Native pointer to the audio track
        `volume` - Output parameter for volume level
      Returns:
        0 on success, <0 on failure

    - #### nativeEnableLocalPlayback

          private int nativeEnableLocalPlayback(long cptr,
                                                int enable)

      Enables or disables local playback of the audio track natively.
      Parameters:
        `cptr` - Native pointer to the audio track
        `enable` - 1 to enable, 0 to disable
      Returns:
        0 on success, <0 on failure

    - #### nativeEnableEarMonitor

          private int nativeEnableEarMonitor(long cptr,
                                             int enable,
                                             int includeAudiFilter)

      Enables or disables ear monitoring through the native API.
      Parameters:
        `cptr` - Native pointer to the audio track
        `enable` - 1 to enable, 0 to disable
        `includeAudiFilter` - 1 to include audio filter, 0 to exclude
      Returns:
        0 on success, <0 on failure

    - #### nativeSetMaxBufferedAudioFrameNumber

          private void nativeSetMaxBufferedAudioFrameNumber(long cptr,
                                                            int number)

      Sets the maximum buffered frame count for the native audio sender.
      Parameters:
        `cptr` - Native pointer to the audio track
        `number` - Maximum number of frames to buffer

    - #### nativeClearSenderBuffer

          private int nativeClearSenderBuffer(long cptr)

      Clears buffered audio frames in the native sender.
      Parameters:
        `cptr` - Native pointer to the audio track
      Returns:
        0 on success, <0 on failure

    - #### nativeSetSendDelayMs

          private void nativeSetSendDelayMs(long cptr,
                                            int delayMs)

      Adjusts the native send delay in milliseconds.
      Parameters:
        `cptr` - Native pointer to the audio track
        `delayMs` - Delay in milliseconds

    - #### nativeSetTotalExtraSendMs

          private int nativeSetTotalExtraSendMs(long cptr,
                                                long totalExtraSendMs)

      Sets the total extra send time in milliseconds at the native layer.
      Parameters:
        `cptr` - Native pointer to the audio track
        `totalExtraSendMs` - Total extra send time in milliseconds
      Returns:
        0 on success, <0 on failure