io.agora.rtc.internal

## Class AgoraAudioFrameObserver

- java.lang.Object
- - io.agora.rtc.internal.AgoraAudioFrameObserver

- All Implemented Interfaces:
    IAudioFrameObserver

      public class AgoraAudioFrameObserver
      extends java.lang.Object
      implements IAudioFrameObserver

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `private IAudioFrameObserver` | `audioFrameObserver`
    `private boolean` | `enableVad`
    `private AgoraAudioVadManager` | `vadManager`
    `private VadProcessResult` | `vadProcessResult`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AgoraAudioFrameObserver(IAudioFrameObserver observer, boolean enableVad, AgoraAudioVadConfigV2 vadConfig)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `destroy()`
    `int` | `getObservedAudioFramePosition()`
    `int` | `onEarMonitoringAudioFrame(AgoraLocalUser agoraLocalUser, AudioFrame frame)` Note: To improve data transmission efficiency, the buffer of the frame object is a DirectByteBuffer.
    `int` | `onMixedAudioFrame(AgoraLocalUser agoraLocalUser, java.lang.String channelId, AudioFrame frame)` Note: To improve data transmission efficiency, the buffer of the frame object is a DirectByteBuffer.
    `int` | `onPlaybackAudioFrame(AgoraLocalUser agoraLocalUser, java.lang.String channelId, AudioFrame frame)` Note: To improve data transmission efficiency, the buffer of the frame object is a DirectByteBuffer.
    `int` | `onPlaybackAudioFrameBeforeMixing(AgoraLocalUser agoraLocalUser, java.lang.String channelId, java.lang.String userId, AudioFrame frame, VadProcessResult vadResult)` Note: To improve data transmission efficiency, the buffer of the frame object is a DirectByteBuffer.
    `int` | `onRecordAudioFrame(AgoraLocalUser agoraLocalUser, java.lang.String channelId, AudioFrame frame)` Note: To improve data transmission efficiency, the buffer of the frame object is a DirectByteBuffer.

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

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

- - ### Field Detail

    - #### audioFrameObserver

          private volatile IAudioFrameObserver audioFrameObserver

    - #### enableVad

          private volatile boolean enableVad

    - #### vadManager

          private volatile AgoraAudioVadManager vadManager

    - #### vadProcessResult

          private volatile VadProcessResult vadProcessResult

  - ### Constructor Detail

    - #### AgoraAudioFrameObserver

          public AgoraAudioFrameObserver(IAudioFrameObserver observer,
                                         boolean enableVad,
                                         AgoraAudioVadConfigV2 vadConfig)

  - ### Method Detail

    - #### destroy

          public void destroy()

    - #### onRecordAudioFrame

          public int onRecordAudioFrame(AgoraLocalUser agoraLocalUser,
                                        java.lang.String channelId,
                                        AudioFrame frame)

      Description copied from interface: `IAudioFrameObserver`
      Note: To improve data transmission efficiency, the buffer of the frame object is a DirectByteBuffer. Be sure to extract the byte array value in the callback synchronously and then transfer it to the asynchronous thread for processing. You can refer to `Utils.getBytes(ByteBuffer)`.
      Specified by:
        `onRecordAudioFrame` in interface `IAudioFrameObserver`
      Parameters:
        `agoraLocalUser` - the local user
        `channelId` - the channel id
        `frame` - the audio frame
      Returns:
        0/1, the return value currently has no practical significance

    - #### onPlaybackAudioFrame

          public int onPlaybackAudioFrame(AgoraLocalUser agoraLocalUser,
                                          java.lang.String channelId,
                                          AudioFrame frame)

      Description copied from interface: `IAudioFrameObserver`
      Note: To improve data transmission efficiency, the buffer of the frame object is a DirectByteBuffer. Be sure to extract the byte array value in the callback synchronously and then transfer it to the asynchronous thread for processing. You can refer to `Utils.getBytes(ByteBuffer)`.
      Specified by:
        `onPlaybackAudioFrame` in interface `IAudioFrameObserver`
      Parameters:
        `agoraLocalUser` - the local user
        `channelId` - the channel id
        `frame` - the audio frame
      Returns:
        0/1, the return value currently has no practical significance

    - #### onMixedAudioFrame

          public int onMixedAudioFrame(AgoraLocalUser agoraLocalUser,
                                       java.lang.String channelId,
                                       AudioFrame frame)

      Description copied from interface: `IAudioFrameObserver`
      Note: To improve data transmission efficiency, the buffer of the frame object is a DirectByteBuffer. Be sure to extract the byte array value in the callback synchronously and then transfer it to the asynchronous thread for processing. You can refer to `Utils.getBytes(ByteBuffer)`.
      Specified by:
        `onMixedAudioFrame` in interface `IAudioFrameObserver`
      Parameters:
        `agoraLocalUser` - the local user
        `channelId` - the channel id
        `frame` - the audio frame
      Returns:
        0/1, the return value currently has no practical significance

    - #### onEarMonitoringAudioFrame

          public int onEarMonitoringAudioFrame(AgoraLocalUser agoraLocalUser,
                                               AudioFrame frame)

      Description copied from interface: `IAudioFrameObserver`
      Note: To improve data transmission efficiency, the buffer of the frame object is a DirectByteBuffer. Be sure to extract the byte array value in the callback synchronously and then transfer it to the asynchronous thread for processing. You can refer to `Utils.getBytes(ByteBuffer)`.
      Specified by:
        `onEarMonitoringAudioFrame` in interface `IAudioFrameObserver`
      Parameters:
        `agoraLocalUser` - the local user
        `frame` - the audio frame
      Returns:
        0/1, the return value currently has no practical significance

    - #### onPlaybackAudioFrameBeforeMixing

          public int onPlaybackAudioFrameBeforeMixing(AgoraLocalUser agoraLocalUser,
                                                      java.lang.String channelId,
                                                      java.lang.String userId,
                                                      AudioFrame frame,
                                                      VadProcessResult vadResult)

      Description copied from interface: `IAudioFrameObserver`
      Note: To improve data transmission efficiency, the buffer of the frame object is a DirectByteBuffer. Be sure to extract the byte array value in the callback synchronously and then transfer it to the asynchronous thread for processing. You can refer to `Utils.getBytes(ByteBuffer)`.
      Specified by:
        `onPlaybackAudioFrameBeforeMixing` in interface `IAudioFrameObserver`
      Parameters:
        `agoraLocalUser` - the local user
        `channelId` - the channel id
        `userId` - the user id
        `frame` - the audio frame
        `vadResult` - the vad result
      Returns:
        0/1, the return value currently has no practical significance

    - #### getObservedAudioFramePosition

          public int getObservedAudioFramePosition()

      Specified by:
        `getObservedAudioFramePosition` in interface `IAudioFrameObserver`